regex

Regular Expressions in PHP

Sorry for unclear description, my English is not good. My problem is that I want to decode a string, and this string has nested content delimited by {}. For example: The string: {any string0{any string 00{any string 000....}}}{any string1}any string. The result I want to get: array[0] = {any string0{any string 00{any string 000....

Python re.IGNORECASE being dynamic

I'd like to do something like this: re.findall(r"(?:(?:\A|\W)" + 'Hello' + r"(?:\Z|\W))", 'hello world',re.I) And have re.I be dynamic, so I can do case-sensitive or insensitive comparisons on the fly. This works but is undocumented: re.findall(r"(?:(?:\A|\W)" + 'Hello' + r"(?:\Z|\W))", 'hello world',1) To set it to sensitive. Is...

Match beginning of words in Mysql for UTF8 strings

Hi, I m trying to match beignning of words in a mysql column that stores strings as varchar. Unfortunately, REGEXP does not seem to work for UTF-8 strings as mentioned here So, select * from names where name REGEXP '[[:<:]]Aandre'; does not work if I have name like Foobar Aándreas However, select * from names where name li...

get entire line with java.util.scanner.hasNext(regex)

I'm doing something in Java that requires input to be matched against the pattern ^[1-5]$. I should have a while loop looping through each line of input, checking it against the pattern, and outputting an error message if it does not. Sudo code: while (regex_match(/^[^1-5]$/,inputLine)) { print ("Please enter a number betwee...

questions on nfa and dfa..

Hi Guys... Hope you help me with this one.... I have a main question which is ''how to judge whether a regular expression will be accepted by NFA and/or DFA? For eg. My question says that which of the regular expressions are equivalent? explain... 1.(a+b)*b(a+b)*b(a+b)* 2.a*ba*ba* 3.a*ba*b(a+b)* do we have to draw the NFA and DFA an...

Why regular expression's "non-capturing" group is not working

In my snippet below, the non-capturing group "(?:aaa)" should be ignored in matching result, so the result should be "_bbb" only. However, I get "aaa_bbb" in matching result; only when I specify group(2) does it show "_bbb". import re string1 = "aaa_bbb" print(re.match(r"(?:aaa)(_bbb)", string1).group()) >>> aaa_bbb ...

regular expression for bit strings with even number of 1s

Let L= { w in (0+1)* | w has even number of 1s}, i.e. L is the set of all bit strings with even number of 1s. Which one of the regular expressions below represents L? A) (0*10*1)* B) 0*(10*10*)* C) 0*(10*1)* 0* D) 0*1(10*1)* 10* According to me option D is never correct because it does not represent the bit string with zero 1s. But ...

Regular expression to match 10-14 digits

I am using regular expressions for matching only digits, minimum 10 digits, maximum 14. I tried: ^[0-9] ...

Regular expression alphanumerics with space

I write regular expression for alphanumerics, but it is not taking space. I want space (whitespace between characters). I write like this: ^[a-zA-Z0-9_]*$ ...

codingBat separateThousands using regex (and unit testing how-to)

This question is a combination of regex practice and unit testing practice. Regex part I authored this problem separateThousands for personal practice: Given a number as a string, introduce commas to separate thousands. The number may contain an optional minus sign, and an optional decimal part. There will not be any superfluous le...

Java Regular Expression. Check if String contains ONLY Letters

How do I check if a String contains only letters in java? I want to write an if statement that will return false if there is a white space, a number, a symbol or anything else other than a-z A-Z. My string must contain ONLY letters. I thought I could do it this way, but I'm doing it wrong: if( ereg("[a-zA-Z]+", $myString)) return tr...

php: deleting words via regular expression

i want to delete the following type of expressions from my script. <a any text here>nothing or space here</a> i can do it by three functions, but i think there is a way shorter. could you help me? thanks in advance ...

.htaccess: RewriteRule problem

i need to much the sentense, if it doesn't contain some words i wrote it like this ^([^news|home|rules|contacts|month_films|archive|ratings])$ but it doesn't work. could you tell me why? thanks ...

regex: find the part, which doesn't contain none of some words

how can i much the sentense, if it doesn't contain none of {word1,word2,word3} where i must put ^ symbol? i think it must looks like this ^([^word1|word2|word3])$ but it doesn't work. could you help? thanks ...

emacs: Is it possible to match strings with balanced parens with emacs regex?

Something like this: http://perl.plover.com/yak/regex/samples/slide083.html In other words I want to match successfully on { { foo } { bar} } but not on { { foo } . I see it's possible in perl, and in .NET. Is it possible in emacs regex? ...

How to check if a given Regex is valid?

Hi folks, I have a little program allowing users to type-in some regular expressions. afterwards i like to check if this input is a valid regex or not. I'm wondering if there is a build-in method in Java, but could not find such jet. Can you give me some advice? Best regards Phil ...

Regular expression help

in twitter when you write @moustafa will change to <a href='user/moustafa'>@moustafa</a> now i want make the same thing when write @moustafa + space its change @moustafa only ...

C# equivalent of Java Punctuation regex

I'm looking to find the equivalent in C# for the equivalent of this regex. Java: public static final String expression = "[\\s\\p{Punct}]"; {Punct} is a reserved character class in Java but I'm not sure how to create the equivalent expression so that the .net regex engine doesn't barf. ...

How Do I Pull Info from String

I am trying to pull dynamics from a load that I run using bash. I have gotten to a point where I get the string I want, now from this I want to pull certain information that can vary. The string that gets returned is as follows: Records: 2910 Deleted: 0 Skipped: 0 Warnings: 0 Each of the number can and will vary in length, but the o...

Regular expressions - how to match the character '<' not followed by ('a' or 'em' or 'strong')?

How would I make a regular expression to match the character '<' not followed by ('a' or 'em' or 'strong') so <hello and <string would match, but <strong wouldn't. UPDATE: Btw, the language I'm using is javascript ...