Possible Duplicate:
The Hostname Regex
I'm trying to use pcrepp (PCRE) to extract hostname from url.
the pcre regular expression is as same as Perl 5 regular expression.
for example:
url = "http://www.pandora.com/#/volume/73";
// the match will be "http://www.pandora.com/".
I can't find the correct syntax of the regex for ...
I need a regex expression for matching a string in quotes and then a white space then a round bracket then a curly bracket.
For example this is the text I want to match in Java:
"'Allo 'Allo!" (1982) {A Barrel Full of Airmen (#7.7)}
What would the regex for this be?
Sorry, but I'm just really lost. I tried a lot of different things b...
I'm using all of the below to take a field called 'code' from my database, get rid of all the HTML entities, and print it 'as usual' to the site:
<?php $code = preg_replace('~&#x([0-9a-f]+);~ei', 'chr(hexdec("\\1"))', $code);
$code = preg_replace('~&#([0-9]+);~e', 'chr("\\1")', $code);
$code = html_entity_decode($code); ?>
H...
Hello.
This is my javascript regex pattern:
url = "http://www.amazon.com/gp";
hostname = /^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)/.exec(url) || [];
// would return "www.amazon.com"
the above regex extracting the hostname from a given url.
I ...
Can anyone give me complete example program how to work with GNU regex functions in gcc C or C++ (http://docs.freebsd.org/info/regex/regex.info.GNU_Regex_Functions.html), with
re_pattern_buffer, re_compile_fastmap?
For example, translate this small Python program:
import re
unlucky = re.compile('1\d*?3')
nums = ("13", "31", "777", "1...
How can I remove text from between square brackets and the brackets themselves?
For example, I need
hello [quote="im sneaky"] world
to become
hello world
Here's what I'm trying to use, but it's not doing the trick
preg_replace("/[\[(.)\]]/", '', $str);
I just end up with
hello quote="im sneaky" world
Thanks
...
I have this simple piece of code in c++:
int main(void)
{
string text = "http://www.amazon.com";
string a,b,c,d,e,f;
pcrecpp::RE re("^((\\w+):\\/\\/\\/?)?((\\w+):?(\\w+)?@)?([^\\/\\?:]+):?(\\d+)?(\\/?[^\\?#;\\|]+)?([;\\|])?([^\\?#]+)?\\??([^#]+)?#?(\\w*)");
if(re.PartialMatch(text, &a,&b,&c,&d,&e,&f))...
For example:
"I don't like these "double" quotes"
and I want the output to be
I don't like these double quotes
...
Regex:
String regexp = "([0-9.]{1,15})[ \t]*([0-9]{1,15})[ \t]*([0-9.]{1,15})[ \t]*(\"(.*?)\"\\s+\\((\\d{4})\\)\\s+\\{(.*?)\\})";
Text:
1000000103 50 4.5 #1 Single (2006)
2...1.2.12 8 2.7 $1,000,000 Chance of a Lifetime (1986)
11..2.2..2 8 5.0 $100 Taxi Ride (2001)
....13.311 9 7.1 $100,000 Name Th...
Is there a regex for social security number (id) in EU?
...
Hi everyone,
I came accross a very strange problem with tr1::regex (VS2008) that I can't figure out the reason for. The code at the end of the post compiles fine but throws an exception when reaching the 4th regular expression definition during execution:
Microsoft C++ exception: std::tr1::regex_error at memory location 0x0012f5f4.....
I have a URL like /admin/editblogentry?page=3&color=blue
I want to alter the 'page' in the url to 1 so that the url becomes
/admin/editblogentry?page=1&color=blue
What is the best way to accomplish this using javascript?
...
I have a huge file that has some lines that need to have a line of dashes underneath them followed by an empty line.
All of these lines start with the same particular word pattern ("Dollars required for") but every other word on the line is different from one line to the next.
For example, the document looks like this at the moment:
...
I have a file that contain lines that looks like this:
>AF001546_1 [88 - 462] 1 MGQQ
>AF001543_1 [88 - 261] ACGT
Not that each line can contain 6 OR 5 fields. What I want to do is to capture
Fields 1,2,3(num only), 5(num only) and last field (ACGT or MGOQ strings).
So the expected output is this:
>AF001546_1 88 462 MGQQ
>AF001543_1 ...
If I have a bunch of text like this
The cat sat on the mat
Expropriations for international monetary exchange ( Currenncy: Dollars,
Value: 50,000)
The cat sat on the mat
Expropriations for international monetary exchange ( Currenncy: Yen)
The cat sat on the mat
Is there a Regular Ex...
I have a text file in which any line that starts with a single word and has no other characters after that should be enclosed inside caret characters.
For example, a line that contains only the following 6 characters (plus the newline):
France
should be replaced with a line that consists of only the following 8 characters (plus the n...
How can I split a string such as "Mar10" into "Mar" and "10" in c#? The format of the string will always be letters then numbers so I can use the first instance of a number as an indicator for where to split the string.
...
Is there a Regular Expression I could use in the Find/Replace feature of my text editor (Jedit) to do the following:
Match any lines in a text file that meet these criteria:
The line ends with a closing parenthesis
An opening parenthesis exists somewhere on the same line
If it matches I need to wrap all of the text on the line - but...
I'm having a hard time finding the regex for the start and end of a file in python.
How would I accomplish this ?
...
I want regular expression that checks
that the string doesnt start with an
empty space.
Some what like this i want to do :
Is the below ValidationExpression right for it :
string ValidationExpression = @"/^[^ ]/";
if (!String.IsNullOrEmpty(GroupName) && !Regex.IsMatch(GroupName, ValidationExpression))
{
}
...