Regular Expression: Numeric range
How do you write a regular expression that matches a numeric range from 0 or 000 to 180 ? ...
How do you write a regular expression that matches a numeric range from 0 or 000 to 180 ? ...
I have some complex regular expressions which I need to comment for readability and maintenance. The Java spec is rather terse and I struggled for a long time getting this working. I finally caught my bug and will post it as an answer but I'd be grateful for any other advice on maintaining regexes As an example I want to comment the sub...
I'm working on a solution to a previous question, as best as I can, using regular expressions. My pattern is "\d{4}\w{3}(0[1-9]|[12][0-9]|3[01])([01][0-9]|2[0-3])([0-5][0-9]){2}" According to NetBeans, I have two illegal escape characters. I'm guessing it has to do with the \d and \w, but those are both valid in Java. Perhaps my synt...
Hey folks, I'm trying to minify multiple CSS files using preg_replace. Actually, I'm only trying to remove any linebreaks/tabs and comments from the file. the following works for me: $regex = array('{\t|\r|\n}', '{(/\*(.*?)\*/)}'); echo preg_replace($regex, '', file_get_contents($file)); But I'd like to do it in a single multiline r...
I'm trying to do validation of a date entered as numbers only. (e.g. 09042009 as 09/04/2009) The code now just checks the length of the date. How would I validate not only length of the date entry but also that it is a real date? What would be the syntax for combining tests and regular expression? Code as it exists now: echo "Plea...
Hi, i'm trying to parse a string of html tag attributes in php. There can be 3 cases: attribute="value" //inside the quotes there can be everything also other escaped quotes attribute //without the value attribute=value //without quotes so there are only alphanumeric characters can someone help me to find a regex that can...
Hi I'm after a regex for C# which will turn this: "*one*" *two** two and a bit "three four" into this: "*one*" "*two**" two and a bit "three four" IE a quoted string should be unchanged whether it contains one or many words. Any words with asterisks to be wrapped in double quotes. Any unquoted words with no asterisks to be uncha...
I have strings like this: http://localhost:2055/web-site-2009/paginas/noticias/**IGP-M recua 0,36% em agosto, aponta FGV**-46.aspx I'd like to remove all characters that could cause trouble on a URL (like ?, |, &, etc.) and the hyphen(-) on the bold part of the string. It's important that I keep the hyphen next to the 46.aspx. What i...
Hey everybody, I'm trying to see what would be a good way to validate a US address, I know that there might be not a proper way of doing this, but I'm going for the basic way: #, Street name, City, State, and Zip Code. Any ideas will be appreciate it. Thanks ...
There is a way to get the name of a captured group in C#? string line = "No.123456789 04/09/2009 999"; Regex regex = new Regex(@"(?<number>[\d]{9}) (?<date>[\d]{2}/[\d]{2}/[\d]{4}) (?<code>.*)"); GroupCollection groups = regex.Match(line).Groups; foreach (Group group in groups) { Console.WriteLine("Group: {0}, Value: {1}", ???...
How do I match U1234, but not \U1234 in Javascript? I can't figure out how to not match the single backslash. The closest I can get is: \[\\]{0}U[0-9]{4}\b But that doesn't work. Any suggestions? ...
Hi, I need to extract all the tags from an HTML file, In such a way that I would end up with either an array containing key=value for each of the attributes, or at least the raw text that makes up the tag. I don't quite get along with regex, much less in PHP, so I would really appreciate some help in this. PD: Some of the tags may sp...
I'm having perl regex matching problems with a network script I have, I've managed to put the behaviour in a small snippet. Take this Perl snippet for Perl 5.10.0 in Debian: #!/usr/bin/perl use warnings; use strict; my $line = "Version: 0\r\n"; my($version) = $line =~ m/^Version:(\s\d+)\r\n$/; print "1st failed \n" if not $version; ...
Given the following sequence: "normal %(b)BOLD% normal" I want to transform this into the following string: "0000000%(b)bbbb%0000000" In other words, '%(b)' specifies that all characters up until the next '%' should be 'b'. All other characters should be '0'. I have tried numerous approaches, including using the RegexKitLite regu...
I'm trying to do a "preg match all" on the response below to get all the binary data. I've tried just about everything imaginable and for the life of me, can't get anything. I was hoping it'd be as simple as doing something like this: preg_match_all("#\n\n(.*)\n--$boundary#",$body,$matches); But I can't get anything. I've tried other...
Hi, My goal is to replace the links in the database with a catchall link. I generally use the REPLACE command for replacing string in the database, but this time I am having difficulty because in order to find the links I need to use regular expressions, and that is simply not working out: UPDATE node_revisions SET body = REPLACE ( `bo...
How would i use the php function preg_match() to test a string to see if any spaces exist? example "this sentence would be tested true for spaces" "thisOneWouldTestFalse" ...
I've got a piece of text that contains another regular expression. Sample text: ...<rege>!^.*$!mailto:[email protected]!</rege>... What I want to match is: mailto:[email protected] This didn't work: $patterns[] = '/<rege>!\^\.\*\$!(.*)!<\/rege>/'; Thoughts? ...
I have an vCard application that needs to read vCard Data, and have found a RegularExpression which gets the FieldName, Encoding and FieldValue from the file, here it is below: ^(?<FIELDNAME>[\w-]{1,})(?:(?:;?)(?:ENCODING=(?<ENC>[^:;]*)|CHARSET=(?<CHARSET>[^:;]*))){0,2}:(?:(?<CONTENT>(?:[^\r\n]*=\r\n){1,}[^\r\n]*)|(?<CONTENT>[^\r\n]*)) ...
match.matches() returns false. This is odd, because if I take this regex and test String to rubular.com, is shows two matches. What am I doing wrong? Pattern regex = Pattern.compile("FTW(((?!ODP).)+)ODP"); Matcher match = regex.matcher("ZZZMMMJJJOOFTWZMJZMJODPZZZMMMJJJOOOFTWMZJOMZJOMZJOODPZZZMMMJJJOO"); if (match.matches()) { Syst...