I have a text which essentially a c-style source file. I need to match a specific character, lets say ':' only when it's outside of a string. Example:
void main() {
int x = rand() % 2;
printf(x ? "heads : tails" : "tails : heads");
// I want to match this ---^ character, but not others
}
For specificity sake I'm using .N...
This may be a silly question but...
Say you have a sentence like:
The quick brown fox
Or you might get a sentence like:
The quick brown fox jumped over the lazy dog
The simple regexp (\w*) finds the first word "The" and puts it in a group.
For the first sentence, you could write (\w*)\s*(\w*)\s*(\w*)\s*(\w*)\s* to put each ...
Field1: Unknown1
Field2: Unknown2
Field3: Unknown3
In my case I want to exclude row starting with "Field2:" which is effectively start marker "Field2:" end marker "\n" and replace with '' including delimiters.
Or what would be regular expression if I wanted to replace
Field2: Unknown\n with Field2: SomethingElse\n
...
I found a regex on http://regexlib.com/REDetails.aspx?regexp_id=73
It's for matching a telephone number with international code like so:
^(\(?\+?[0-9]*\)?)?[0-9_\- \(\)]*$
When using with PHP's preg_match, the expression fails? Why is that?
...
Can some one suggest regular expression for below text
Signature
text text some more text
text
...
text )
I tried Signature\n.*\) but this only works for
Signature
text )
Basically an expression which starts with a given text, allows multiple new lines, and ends with ).
Thanks
...
Which regular expression engine does Java uses?
In a tool like RegexBuddy if I use
[a-z&&[^bc]]
that expression in Java is good but in RegexBuddy it has not been understood.
In fact it reports:
Match a single character present in
the list below [a-z&&[^bc]
A character in the range between a and z : a-z
One of the cha...
I don't understand why with this regex the method returns false;
Pattern.matches("\\bi", "an is");
the character i is at a word boundary!
...
First question : I want to replace all characters other than alphanumeric and Special Letters. For example , somestringğüş iöç123456!@#$%^&*()_+ to somestringğüş iöç123456
Second: For example , some---example--long-string to some-example-long-string
I do not really know regexp , so I need 2 simple regexp strings.Thank you
...
Is this regex perfect for any url ?
preg_match_all(
'/([www]+(\.|dot))?[a-zA-Z0-9_\.-]+(\.|dot){1,}[com|net|org|info\.]+((\.|dot){0,}[a-zA-Z]){0,}+/i',
$url, $regp);
...
What is the regex to match xxx[any ascii char here, spaces included]+xxx?
I am trying xxx[(\w)(\W)(\s)]+xxx but it doesn't seem to work.
...
How can I write a regex that will put the first line in a group, and then everything else in a second group?
...
Would the second match a line ending, while the first would not?
...
Hi,
I am not much familiar with regular expressions.
I want help for following regular exceptions:
1. String start with alpha word and then followed by any alpha or number. e.g. Abc 20 Jan to 15 Dec
2. String for a decimal number. e.g. 450,122,224.00
3. Also to check if String contain any pattern like 'Page 2 of 20'
Thanks.
...
I am trying to create a .NET Regex to parse a CSS font declaration, which takes following form:
font: italic small-caps bold xx-small 3.0em "Times New Roman", Times, serif;
According to the CSS specification, all of the elements of the declared value are optional, and I have successfully created Regexes that match the first five eleme...
I have html code as a string variable
like a = "<span> Spain will win ....... </span>"
and I want to heightlight "spa" in the String.
I have to use RegExp, How should I write the pattern that it ignores the "spa" on span tag, but highlight in Spain.
Thanks
...
If I have a string like so ..
There is a lot of white space.
And I want to remove all the unwanted space in Ruby's regex.. How do you identify white space and remove it so that there will still be at least one white space between all the words?
So far I have :
gsub(/\s{2,}/, '')
B...
Possible Duplicate:
Useful Regular Expression Tutorial
Hello,
I recently started coding in javascript.
I came across "Regular Expressions" while I'm searching (goolgling) to validate forms (name, email ID's, etc.)
Can someone help this newbie coder by explaining:
What are regular expression?
How are they useful in program...
I have the following text:
3/1
I want to amend it to be:
3/1 port id
Thanks
...
I'm trying to find out how I can compare 2 lists of RPMS (Currently installed) and (Available in local repository) and see which RPMS are out of date. I've been tinkering with regex but there are so many different naming standards for RPMS that i can't get a good list to work with. I don't have the actual RPMS on my drive so i can't do r...
I'm using Jquery 1.3 and this is the code i've isolated the code that throws an error in firebug as follows: "G is undefined"
var product = $("#id :selected"); // This is a dropdown
var prodTxt = product.text(); // Returns string as expected
var price = prodTxt.match(/\$[0-9]{3}/); // Commenting this out...