Skip to content
Advertisement

Tag: regex

RegEx to exclude a space between country code and phone number itself?

My goal is to create two groups from a full phone number(which is given in a string): First group: +xyz (any three numbers with a plus sign) Second group: following 7 or 8 digits So, my regex is: ((D?[0-9]{3})(D?s?[0-9]{7,8})) The problem I encountered was that if I have, for example +358 55667788, whitespace after a country code is still included

Using regular expression for a field name in a Django

I have a model in Django that has the fields photo_1, photo_2, photo_3 and many other fields that does not contains the “photo” string on their names. Also, the photo fields can be blank, so I can find some rows with empty photo fields. For the html template, is there a way to go through the fields named “^photo_[0-9]*$” and

escaping square brackets from string in dataframe

I have a dataframe where i am try to clean the data from all cols. There are some annomalies in teh data like this: “[n], [ta], [cb]” basically anything in square brackets i want to ignore and replace with a space. I have this: this works except I still get the square brackets in the data but they are just

Python Regex pL matching issues

I’m trying to match a list of keywords I have, taking care to include all Latin characters (e.g accented). Here’s an example gives: Which looks correct. However: gives: This is wrong, as I expect a match for “u blah”. I’ve tried to also use Pythons built in re module, but I cannot get it to work with pL or p{Latin}

Find bit sequences that do not include specific sequence

I’m trying to find all non-overlap bit sequences satisfied the following constraints: starts with 0 ends with 110 or 111 does not contain 000 Here is my non-regex code in python: My current regex pattern is (0(^(?!000))*(?:110|111)). It doesn’t accept any bit between starting 0 and ending bits. For example, 010110 will return 0110 instead of expected 010110. Adding d*?,

Regex to keep one choice in square bracket

I am trying to write a regex to replace the whole square bracket with the first choice. For example, [ choice A | choice B ] I want to replace the previous square bracket as a whole with choice A. However, when I have more than one of these brackets: [ choice A | choice B ] and choose between

Advertisement