I have a string like "test http://www.bing.com test". I want to extract just the url ("http://www.bing.com") from this string. How do I go about doing it? How would the regex look like?
6007
How can I check if a given string is a valid URL address?  My knowledge of regular expressions is basic and doesn't allow me to choose from the hundreds of regular expressions I've already seen on the web.
10277
I need to build a function which parses the domain from a URL.  So, with   http://google.com/dhasjkdas/sadsdds/sdda/sdads.html   or  http://www.google.com/dhasjkdas/sadsdds/sdda/sdads.html  it should return google.com  with   http://google.co.uk/dhasjkdas/sadsdds/sdda/sdads.html  it should return google.co.uk.
32215
I haven't used regular expressions at all, so I'm having difficulty troubleshooting. I want the regex to match only when the contained string is all numbers; but with the two examples below it is matching a string that contains all numbers plus an equals sign like "1234=4321". I'm sure there's a way to change this behavior, but as I said, I've never really done much with regular expressions.  string compare = "1234=4321"; Regex regex = new Regex(@"[\d]");  if (regex.IsMatch(compare)) {      //true }  regex = new Regex("[0-9]");  if (regex.IsMatch(compare)) {      //true }   In case it matters, I'm using C# and .NET2.0.
104807
Assume I have created a compiled re:  x = re.compile('^\d+$')   Is there a way to extract the pattern string (^\d+$) back from the x?
90488
I would like to redirect a URL with uppercase characters http://localhost/A/B to a lowercase version http://localhost/a/b using the .htaccess file. Using regex I can capture A and B but is it possible to convert them to lowercase?
47023
Say I have the string "User Name:firstname.surname" contained in a larger string how can I use a regular expression to just get the firstname.surname part?  Every method i have tried returns the string "User Name:firstname.surname" then I have to do a string replace on "User Name:" to an empty string.  Could back references be of use here?  Edit:  The longer string could contain "Account Name: firstname.surname" hence why I want to match the "User Name:" part of the string aswell to just get that value.
3154
I have a string User name (sales) and I want to extract the text between the brackets, how would I do this?   I suspect sub-string but I can't work out how to read until the closing bracket, the length of text will vary.
5132
Is there a quick way to find every match of a regular expression in Ruby? I've looked through the Regex object in the Ruby STL and searched on Google to no avail.
62677
I am writing a Java utility which helps me to generate loads of data for performance testing.  It would be really cool to be able to specify a regex for Strings so that my generator spits out things which match this.  Is there something out there already baked which I can use to do this?  Or is there a library which gets me most of the way there?  Thanks
55644
I'm looking for Python code that removes C and C++ comments from a string. (Assume the string contains an entire C source file.)  I realize that I could .match() substrings with a Regex, but that doesn't solve nesting /*, or having a // inside a /* */.  Ideally, I would prefer a non-naive implementation that properly handles awkward cases.
41680
If I have the following string:  string s = "abcdefghab";   Then how do I get a string (or char[]) that has just the characters that are repeated in the original string using C# and LINQ. In my example I want to end up with "ab".  Although not necessary, I was trying to do this in a single line of LINQ and had so far come up with:  s.ToCharArray().OrderBy(a =&gt; a)...
1707
I have several strings in the rough form:  [some text] [some number] [some more text]   I want to extract the text in [some number] using the Java Regex classes.  I know roughly what regular expression I want to use (though all suggestions are welcome). What I'm really interested in are the Java calls to take the regex string and use it on the source data to produce the value of [some number].  EDIT: I should add that I'm only interested in a single [some number] (basically, the first instance). The source strings are short and I'm not going to be looking for multiple occurrences of [some number].
110705
I'm trying to construct a hyperlink from a URL and a name in different cells.  a1 = http://www.example.com/ b1 = example c1 = &lt;a href="http://www.example.com/"&gt;example&lt;/a&gt;   What I want that is the URL in A1 to is made into a hyperlink with the name taken from B1:  &lt;a href="http://www.example.com/"&gt;example&lt;/a&gt;   I created a formula, but it's not working  &lt;a href=&amp;”=a1”&gt;&amp;”=b1”&lt;/a&gt;   should result in  &lt;a href="http://www.example.com/"&gt;example&lt;/a&gt;
23875
What does double slashes often found in URL's mean exactly?  For example:   http://www.example.com/A/B//C/   Please note that I'm not referring to the beginning right after http:.
3211
I have this gigantic ugly string: J0000000: Transaction A0001401 started on 8/22/2008 9:49:29 AM J0000010: Project name: E:\foo.pf J0000011: Job name: MBiek Direct Mail Test J0000020: Document 1 - Completed successfully  I'm trying to extract pieces from it using regex. In this case, I want to grab everything after Project Name up to the part where it says J0000011: (the 11 is going to be a different number every time). Here's the regex I've been playing with: Project name:\s+(.*)\s+J[0-9]{7}:  The problem is that it doesn't stop until it hits the J0000020: at the end. How do I make the regex stop at the first occurrence of J[0-9]{7}?
15365
In Perl, what is a good way to perform a replacement on a string using a regular expression and store the value in a different variable, without changing the original?  I usually just copy the string to a new variable then bind it to the s/// regex that does the replacement on the new string, but I was wondering if there is a better way to do this?  $newstring = $oldstring; $newstring =~ s/foo/bar/g;
7509
I try to write a simple Markdown parser in JavaScript. Therefore I want to check for the [link content][link id] syntax. I use the following code:  data = data.replace( /\[(.*?)\][ ]*\[([0-9]+)\]/g, '&lt;a href="$2"&gt;$1&lt;/a&gt;' );   It works well, but now I want to do this with a RegExp object. So I set up the following bit of code:  var r = new RegExp( '\[(.*?)\][ ]*\[([0-9]+)\]', 'g' ); data = data.replace( r, '&lt;a href="$2"&gt;$1&lt;/a&gt;' );   But it doesn't work. It even says that my regular expression (which works since the first example does a good job) is invalid:     unmatched ) in regular expression   I think it must have to do with some RegExp-object peculiarities I am not aware of. What am I doing wrong and how can the problem be solved?