regex

Regex to replace string

I tried to replace   elements in a string using .NET regex - with no luck :) Assume the following string:  AA A  C D   A Some Text   here The rules Do not replace at beginning of line Do only replace single occurrences Do not replace if a space is before or after it (optional) The ...

Regex to match 2 different parts of a line

I'm working in lua, and i need to match 2 parts of a line that's taken in through file IO. I'm inexperienced with regexes and i'm told lua doesn't have full regex support built in (but i have a library that provides that if need be). Can someone help me with building regexes to match the parts necessary? "bor_adaptor_00.odf" 3.778 ...

Find strings of length 10 with regex

I want to use a regular expression to find strings which are exactly 10 characters long and begin with "7". Please could someone tell me how? ...

Trouble with a word limit range regular expression....

I am using a regular expression to limit words entered in a textbox field to 250-500 words. (((^\s*)*\S+\s+)|(\S+)){250,500} Since I know little to nothing about regular expressions, I had copied it from another website. I get the validation error regardless of how many words are entered. Here is the page that the form is on, if you w...

Regex to match tags in comments.

I want to get a regex which will match a tag in a java comment so I can replace it with a .net comment. eg I have this: /** * Some method description * * @param paramName Parameter description * which may span more than 1 line * @return return value. * @throws ExceptionName some exception description * again may span...

Use of \G boundary matcher in Java

Hi: I've been learning regex with java. I wanted to know if it makes sense to use \G while using java's matcher. I couldn't find any example of \G used with java :( Doing something like this would not have the same output as using \G? String a = "Pruebaprueba"; Matcher matcher = Pattern.compile("(\\w)").matcher(a); while ( matcher.find...

Javascript storing regex in a variable

I have this line of code in javascript var re = (http|ftp|https):\/\/[\w\-_]+(\.[\w\-_]+)+([\w\-\.,@?^=%&:/~\+#]*[\w\-\@?^=%&/~\+#])? Usually I encapsulate the regex syntax with the / characters but since they are found within the regex it screws up the encapsulation. Is there another way how I can store it inside the variable...

what this php regex does?

$str = preg_replace('#([\x00-\x1F])#e', '"\x" . sprintf("%02x", ord("\1"))', $str); ...

Is it possible to make re find the smallest match while using greedy characters

Disclaimer: I'm not a regex expert. I'm using Python re module to perform regex matching on many htm files. One of the patterns is something like this: <bla><blabla>87765.*</blabla><bla> The problem I've encountered is that instead of finding all (say) five occurrences of the pattern, it will find only one. Because it welds all the o...

Code to parse capture groups in regular expressions into a tree

I need to identify (potentially nested) capture groups within regular expressions and create a tree. The particular target is Java-1.6 and I'd ideally like Java code. A simple example is: "(a(b|c)d(e(f*g))h)" which would be parsed to "a(b|c)d(e(f*g))h" ... "b|c" ... "e(f*g)" ... "f*g" The solution should ideally account for cou...

regular expression for content within braces

hi there, is there a regular expression to match the content within braces. For example with the following: d = {'key': {'a': [1,2,3]}} I would want to match {'key': {'a': [1,2,3]}} and {'a': [1,2,3]}, but not {'key': {'a': [1,2,3]} ...

how to achieve mod_rewrite functionality in text editor's search and replace?

RewriteRule ^/?page/?([a-zA-Z0-9,-]+)$ $1.php [L] is it possible for a text editor to find and replace a string in a manner as how apache's mod_rewrite does it? i mean for example, in a text-file, i'd like to enclose all email addresses inside double qoutes, by inputting [a-zA-Z_]@[a-zA-Z-]+\.[a-zA-Z.]+ in the "find what" field and "$...

C# Need to locate web addresses using REGEX is that possible?

C# Need to locate web addresses using REGEX is that possible? Basically I need to parse a string prior to loading it into a WebBrowser myString = "this is an example string http://www.google.com , and I need to make the link clickable"; webBrow.DocumentText = myString; Basically what I want to happen is a replace of the web address ...

Constrain ASP.NET MVC Route Parameter Value (Exactly 1 Letter A-Za-z)

How can I constrain an MVC route parameter to be only A-Za-z and exactly 1 letter? (Looking for the validation Regex). Thank you! ...

How to enable whitespace insensitive mode of regular expression in PHP?

I've tried "m" modifier,but not working: $reg = '/... /m'; preg_match($reg,...,$match); EDIT Or maybe I need a modifier that can ignore white space like ENTER,TAB and so on. Because when I remove the white space in my regex it works. EDIT AGAIN: I need a modifier so that regular expression "/aaaa b/", "/aaaa b/" are t...

not quotes in regex

i'm having a string var str = "hello -- (world)"; using regex and replace str.replace([a-z],"0"); replaces all the alphabets. but i need to replace other than alphabet. ...

how to get html div element innertext by id using regular expression in C#

I'm getting full html code using WebClient. But i need to get specified div from full html using regular expression. for example: <body> <div id="main"> <div id="left" style="float:left">this is a <b>left</b> side:<div style='color:red'> 1 </div> </div> <div id="right" style="float:left"> main side</div> <div> </body> ...

Regex for a-z , hypen (-) and å ä ö in Zend Route Regex

Hi! I want to route url through Zend route regex with Swedish character and here is my regex in xml configuration: ..... ([a-z\-å|ä|ö]+) ..... Still, the route doesn't behave as I expect. It doesn't redirect when the link contains å, ä, or ö I have tried to change to [a-zåäö\-]+ but it also gives the same result.. anyone can help? ...

Casting regex arguments into a list

Greetings, A script is working on one or more files. I want to pass the filenames (with regex in them) as arguments and put them in a list. What is the best way to do it? For example I would accept the following arguments: script.py file[1-3].nc #would create list [file1.nc, file2.nc, file3.nc] that I can work on script.py file*.nc #w...

How do I save matched parts of a regex in Perl?

I want to sort out all APIs in the following text file: DLL Name: msvcrt.dll ... DLL Name: msvcrt.dll ... DLL Name: KERNEL32.dll ... DLL Name: WSOCK32.DLL I thought of something like $infostring = lc($infostring); while ($infostring =~ /dll name:/g) { print "found dll\n"; } the only problem is, how to get the actual dll names or a...