Is Good To Know Regular Expressions To Build a Language?
I'm reading Flex & Bison from O'Reilly, and would like to know if learning Regular Expressions beforehand will help in developing a programming language? ...
I'm reading Flex & Bison from O'Reilly, and would like to know if learning Regular Expressions beforehand will help in developing a programming language? ...
Hi, if i have a string of text like below, how can i collect the contents of the brackets in a collection in c# even if it goes over line breaks? eg... string s = "test [4df] test [5yu] test [6nf]"; should give me.. collection[0] = 4df collection[1] = 5yu collection[2] = 6nf ...
In the python installation on my PC there is a sweet script in c:\python26\tools\scripts called redemo.py. It's a simple tk app for testing regular expressions. I wish I could get it--or something like it--running on my Mac, but I don't know how. The script doesn't appear to be part of the python installation on my mac. Ideas? ...
Hi all. How do I use string.Format to enter a value into a regular expression, where that regular expression has curly-braces in it already to define repetition limitation? (My mind is cloudy from the collision for syntax) e.g. The normal regex is "^\d{0,2}", and I wish to insert the '2' from the property MaxLength Thanks. ...
I have a string like: [a b="c" d="e"]Some multi line text[/a] Now the part d="e" is optional. I want to convert such type of string into: <a b="c" d="e">Some multi line text</a> The values of a b and d are constant, so I don't need to catch them. I just need the values of c, e and the text between the tags and create an equivalent ...
Hi, I have a bunch of strings, each containing an anchor tag and url. string ex. here is a link <a href="http://www.google.com">http://www.google.com</a>. enjoy! i want to parse out the anchor tags and everything in between. result ex. here is a link. enjoy! the urls in the href= portion don't always match the link tex...
The Greedy Option of Regex is really needed? Lets say I have following texts, I like to extract texts inside [Optionx] and [/Optionx] blocks [Option1] Start=1 End=10 [/Option1] [Option2] Start=11 End=20 [/Option2] But with Regex Greedy Option, its give me Start=1 End=10 [/Option1] [Option2] Start=11 End=20 Anybody need like that?...
Hi i would like to parse following string to get the value "46.4400 INR" <div id=currency_converter_result>1 USD = <span class=bld>46.4400 INR</span> <input type=submit value="Convert"> </div> What regular expression do i need to use for this? Please help me out to get out of this Thanks in Advance KAMAL CHALLA ...
Hello Guys, i'm not very firm with regular Expressions, so i have to ask you: How to find out with PHP if a string contains a word starting with @ ?? e.g. i have a string like "This is for @codeworxx" ??? I'm so sorry, but i have NO starting point for that :( Hope you can help. Thanks, Sascha ...
I'm trying to put some anti sql injection in place in java and am finding it very difficult to work with the the "replaceAll" string function. Ultimately I need a function that will convert any existing \ to \\, any " to \", any ' to \', and any \n to \\n so that when the string is evaluated by MySQL SQL injections will be blocked. I'v...
hey guys, now i have an eregi_replace Problem: I have this $subject = "This is for @codeworxx - you have to try first!"; $text = eregi_replace('(((@))[-a-zA-Z0-9]+)','<a href="http://www.google.de/\\1">\\1</a>', $subject); echo $text; Everything works fine, but the <a href="http://www.google.com/@codeworxx">@codeworxx&...
I have been looking around for a regex expression that will spit out just the 'stackoverflow' part and no www. or .com etc. All I could find was to check if the url's were valid... I have used php's url filter to determine that much I now am looking to determine which site it is. I have never written an expression before so I am hoping ...
Edit: indent -bap foo.cpp works Is there any easy way to insert a new line or insert a text before the beginning of every function definition in C++ file? int main() { return 0; } void foo() { } becomes int main() { return 0; } void foo() { } ...
Let's say for example that I have a regular expression like this: "The quick (red|brown|blue|yellow) fox (jumps|leaps) over the lazy (dog|cat)." This regex has 3 grouped components - if it's matched against a given string, the regex api would allow you to easily extract the value inside each group. Now let's say I have 3 strings: [...
I am trying to wrap some words with HTML tags, for that I am using regular expressions. I am almost there: This is my regexp /((apple|banana|cherry|orange)\b\s?)+/gi and this is my replacement: <em>$&</em> which works perfectly for my example text: Apple Banana apple cherry, Cherry orange and Oranges Apple, Banana the result be...
Hey guys. I am trying to match the FDSize: in the following: Gid: 48 48 48 48 FDSize: 64 Groups: 48 425 VmPeak: 289928 kB It comes from /proc/status is not fixied length, and neither is the lines above or below. Can any one help? Thanks ...
When I search the db for a certain value, say a singular noun like "party", I want to be able to get the value "party" from the db, even though it's actually "parties". For that I thought about replacing the -ies suffix for -y, which didn't have any conspicuous exceptions (maybe "lies"). Is there a MySQL equivalent to the PHP Preg_Repla...
I have no experience using regular expressions in PHP, so I usually write some convoluted function using a series of str_replace(), substr(), strpos(), strstr() etc (you get the idea). This time I want to do this correctly, I know I need to use a regex for this, but am confused as to what to use (ereg or preg), and how exactly the synta...
While it's absolutely true that regexp are not the right tool to fully parse HTML documents, I am seeing a lot of people blindly disregarding any question about regexp if they as much as see a single HTML tag in the proposed text. Since we see a lot of examples of regexp not being the right tool, I ask your opinion on this: what are th...
I'm trying to transfer the following URL validation function from my PHP code to my javascript code: this.validate_url = function(field) { var pattern = new RegExp("^((ht|f)tp(s?)\:\/\/|~/|/)?([\w]+:\w+@)?([a-zA-Z]{1}([\w\-]+\.)+([\w]{2,5}))(:[\d]{1,5})?((/?\w+/)+|/?)(\w+\.[\w]{3,4})?((\?\w+=\w+)?(&\w+=\w+)*)?"); ...