regex

What is the regular expression for matching that contains no white space in between text?

Hi, I am looking for a regular expression for matching that contains no white space in between text but it may or may not have white space at start or end of text. ...

Mod rewrite with multiple query strings

Hi, I'm a complete n00b when it comes to regular expressions. I need these redirects: (1) www.mysite.com/bike.php?id=001&product=Product-Name&source=Source-Name should become -> www.mysite.com/Source-Name/001-Product-Name (2) www.mysite.com/car.php?id=002&product=Product-Name&source=Source-Name should become -> www.mysite.com/Sourc...

preg_match and long strings

Hi, This is the preg_match i am trying to use to find specific text in text file. if (preg_match($regexp,$textFile,$result) > 0) { echo "Found ".$result[0]; } else { echo "Not found"; } However, the result is always Found and nothing more. The result array is empty. Now i read that preg_match can't work with long strings. My...

How can I use Boost::regex.hpp library in C++?

I tried to use Boost library but I failed, see my code: #include "listy.h" #include <boost/regex.hpp> using namespace boost; ListyCheck::ListyCheck() { } ListyCheck::~ListyCheck() { } bool ListyCheck::isValidItem(std::string &__item) { regex e("(\\d{4}[- ]){3}\\d{4}"); return regex_match(__item, e); } When I tried to com...

How to check whether a String fully matches a Regex in Scala?

Assume I have a Regex pattern I want to match many Strings to. val Digit = """\d""".r I just want to check whether a given String fully matches the Regex. What is a good and idiomatic way to do this in Scala? I know that I can pattern match on Regexes, but this is syntactically not very pleasing in this case, because I have no groups...

Regex matching "four characters, followed by an unknown No of digits."

An example of how the Strings may look: TADE000177 TADE007,daFG TADE0277 DFDFG Thank you! ...

Regular Expression Sanitize (PHP)

Hello, I would like to sanitize a string in to a URL so this is what I basically need. Everything must be removed except alphanumeric characters and spaces and dashed. Spaces should be converter into dashes. Eg. This, is the URL! must return this-is-the-url Thanks ...

Find and Replace with Notepad++

I have a document that was converted from PDF to HTML for use on a company website to be referenced and indexed for search. I'm attempting to format the converted document to meet my needs and in doing so I am attempting to clean up some of the junk that was pulled over from when it was a PDF such as page numbers, headers, and footers. l...

How to deal with the new line character in the Silverlight TextBox

When using a multi-line TextBox (AcceptsReturn="True") in Silverlight, line feeds are recorded as \r rather than \r\n. This is causing problems when the data is persisted and later exported to another format to be read by a Windows application. I was thinking of using a regular expression to replace any single \r characters with a \r\n,...

Regular expression on a URL

I need to be able to catch when the URL contains a image of multiple file types or follow this syntax. http://localhost:8080/fdlic-web/webpic/101 Here is what i have so far. (.*)(jpg|gif|png|bmp|jpeg|webpic/(\d+))$ ...

Search for a String and replace it with a variable

Hello, I am trying to use regular expression to search a document fo a UUID number and replace the end of it with a new number. The code I have so far is: read_file = open('test.txt', 'r+') write_file = open('test.txt', 'w') r = re.compile(r'(self.uid\s*=\s*5EFF837F-EFC2-4c32-A3D4\s*)(\S+)') for l in read_file: m1 = r.match(l) ...

Regex pattern failing

I am trying to strip out all things that are in a string that are not a letter number or space so I created the regex private static Regex _NonAlphaChars = new Regex("[^[A-Za-z0-9 ]]", RegexOptions.Compiled); however When I call _NonAlphaChars.Replace("Scott,", ""); it returns "Scott," What am I doing wrong that it is not matching th...

Perl Regular Expression [] for <>

So I am trying to read an XML file into a string in Perl and send it as part of a SOAP message. I know this is not ideal as there are methods for SOAP sending files, however, I am limited to having to use the SOAP that is set up, and it is not set up for sending with file support. Therefore I need to parse out the markup tags <> and re...

Regex match all newline characters within <p> in PHP

I have the following sample set of data: <p>first line\n second line\n third line\n</p> first line\n second line\n third line\n Using regex, how could I match on the newline characters, but only when they are within the paragraph tags. This code would be used within php. ...

How to validate a domain name using Regex & Php?

Hi, I want a solution to validate only domain names not full urls, The following example is what i'm looking for: domain.com -> true domain.net/org/biz... -> true domain.co.uk -> true sub.domain.com -> true domain.com/folder -> false domµ*$ain.com -> false Thank you ...

javascript regular expression search a pattern A(xyz).

I need to find all substrings from a string that starting with a given string following with a left bracket and then any legal literal and then the right bracket. For example, a string is abcd(xyz)efcd(opq), I want to a function that returns "cd(xyz)" and "cd(opq)". I wrote a regular expression, but it returns only cd( and cd(... ...

Extracting XML that matches starting and ending patterns

I am using sed to extract parts of an XML I am interested in: sed '/<car car_id="BMW" year="1999"/,/</car>/p' input So what I really would like to get back is: <car car_id="BMW" year="1999" color="blue> ... </car> Instead I get back a bunch of other car elements. ...

What does the following Regex expression do?

Hi, I would like to understand what the following code is doing. This logic is part of a routine to strip out html from the body of an email message. mBBSREgEx.IgnoreCase = True mBBSREgEx.Global = True mBBSREgEx.Pattern = "<[^>]*>" sResult = mBBSREgEx.Replace(sResult, "") Thank you, Jim Ok, if I wanted to change the routine to stri...

Using jQuery to find a substring

Say you have a string: "The ABC cow jumped over XYZ the moon" and you want to use jQuery to get the substring between the "ABC" and "XYZ", how would you do this? The substring should be "cow jumped over". Many thanks! ...

Regular expression to use which matches text before .html and after /

With this string http://sfsdf.com/sdfsdf-sdfsdf/sdf-as.html I need to get sdf-as with this hellow-1/yo-sdf.html I need yo-sdf ...