[Solved] Replace [1-2] in to 1 in Python

You could use a regex like: ^(.*)\[([0-9]+).*?\](.*)$ and replace it with: $1$2$3 Here’s what the regex does: ^ matches the beginning of the string(.*) matches any character any amount of times, and is also the first capture group\[ matches the character [ literally([0-9]+) matches any number 1 or more times, and is also the second … Read more

[Solved] Regular expression for SSN and phone number [closed]

You might try: ^(?!((\\d{9})|(\\d{3}-\\d{2}-\\d{4})|(\\d{3}-\\d{3}-\\d{3}))$).* To explain, if we read the query you provided: ^((?!\\d[9]$)|(?!(\\d{3}-?\\d{2}-?\\d{4}$)|(?!(\\d{3}-?\\d{3}-?\\d{3})$)$ We could read that: is not followed by xxxxxxxxx OR is not followed by xxx-xx-xxxx OR is not followed by xxx-xxx-xxx (in my version at the top, I rephrased this to be: is not (xxxxxxxxx OR xxx-xx-xxxx OR xxx-xxx-xxx).). Any string … Read more

[Solved] Regular expression to remove fancy apostrophe [closed]

You can use \u to allow any unicode character. If you have a limited set of unsupported characters that can be listed, then you can use character class negation by enclosing the unsupported characters in [^ and ]. 1 solved Regular expression to remove fancy apostrophe [closed]

[Solved] Convert specific eregi_replace to preg_replace function [closed]

But to help. Just add delimeters to the begining and end of the pattern, I used # and escape any delimiters that are in the pattern with \ so the engine knows its not a delimeter, so \#: $sText = preg_replace(‘#(((f|ht){1}tp://)[-a-zA-Z0-9@:%_+.~\#?&//=]+)#’, ‘<a href=”https://stackoverflow.com/questions/19717752/” target=”_blank”><font color=”black”>\1</font></a>’, $sText); 3 solved Convert specific eregi_replace to preg_replace function [closed]

[Solved] Regular expression to validate input from 4 or 5 character the first 3 should be alwas letters [closed]

The regular expression could look like this: ^[a-zA-Z]{3}[0-9]{1,2}$ ^ is denoting the beginning of the string [a-zA-Z] is a character class that includes all uppercase and lowercase letters from A to Z {3} requires three consecutive occurences of that aforementioned character class [0-9] is a character class that includes all numbers from 0 to 9 … Read more

[Solved] Check words that start and end with same letter in C#

You could use regex capturing group. if(Regex.IsMatch(temp,@”^([a-zA-Z])[a-zA-Z]{3,}\1$”)) It should match the words which starts and endswith the same letter and the word must contain atleast 5 letters. For greater than 5 letters, just change the number 3 to 4. 3 solved Check words that start and end with same letter in C#

[Solved] Regex pattern for split

This regex does the trick: “,(?=(([^\”]*\”){2})*[^\”]*$)(?=([^\\[]*?\\[[^\\]]*\\][^\\[\\]]*?)*$)” It works by adding a look-ahead for matching pairs of square brackets after the comma – if you’re inside a square-bracketed term, of course you won’t have balanced brackets following. Here’s some test code: String line = “a=1,b=\”1,2,3\”,c=[d=1,e=\”1,11\”]”; String[] tokens = line.split(“,(?=(([^\”]*\”){2})*[^\”]*$)(?=([^\\[]*?\\[[^\\]]*\\][^\\[\\]]*?)*$)”); for (String t : tokens) System.out.println(t); Output: … Read more

[Solved] Check where number 1 is in decimal number

I wouldn’t rely too much on the approach you posted in your answer. Use the following function instead: function index_of_one($dec) { // maximum precision is 15 $str = str_replace(‘.’,”,sprintf(‘%.15f’, $dec)); $pos = strpos($str, ‘1’); if ($pos === false) { return -1; } return ($pos + 1); } Example: $dec1 = 1.00000000; $dec2 = 0.10000000; $dec3 … Read more

[Solved] R: Remove list type within dataframe

Try to do this library(‘stringr’) apply(data, 1, function(x) str_c(x$columnnane,collapse=”,”)) where, data is you dataframe and columnname is the column containing list. edited answer out = do.call(rbind, lapply(data, function(x) str_c(x,collapse=”, “))) where data is your list object if the list is stored inside a dataframe then pass the column in place of the data above like … Read more