regex

Regular expression for email

Possible Duplicate: What is the best regular expression for validating email addresses? I am using this particular regular expression for checking emails. "^[A-Za-z0-9](([a-zA-Z0-9,=\.!\-#|\$%\^&\*\+/\?_`\{\}~]+)*)@(?:[0-9a-zA-Z-]+\.)+[a-zA-Z]{2,9}$" The issue I have is that, this allows periods before the "@" symbol. Is ther...

Regex '''string''' to <b>string</b>

I need a regex to replace '''string''' with <b>string</b> this one wont work: '/'''(.*?)'''/' ...

IIS7 URL Rewrite Regular Expression

I am trying to set up IIS7 so the a URL with the pattern: www.test.com/docs/ADocument.pdf will get redirected to the URL www.test.com/1.0/docs/ADocument.pdf I am having trouble with the regular expression. The pattern should work with any page at the end of the url. ...

Regex: Finding strings that doesn't start with X

I am completely hopeless with regular expressions... I have a Velocimacro named #addButton, and I have a JS function named addButton(). Now I want to find all the places the JS function is called. So I need to search for "addButton", where "addButton" doesn't start with the hash key. Any ideas? ...

Regex to match content of HTML body in PHP

I need a regex in php for matching contents between tags of an element, e.g. <body> and </body> with the perl compatible preg_match. So far I tried with: // $content is a string with html content preg_match("/<body(.|\r\n)*\/body>/", $content, $matches); print_r($matches); …but the printout is an empty array. ...

Help with preg_replace, stop at non alpa_numeric character

I need some help improving this function I made for parsing the links in a Twitter. It creates links for hashtags and @replys. It all works fine, the problem is if a hashtag or @reply has a punctuation character at the end with no space, it gets added to the HREF URL. For example if I Tweeted "I really like #pizza, and #pop", the link f...

Find spaces in anchor links

We've got a large amount of static that HTML has links like e.g. <a href="link.html#glossary">Link</a> However some of them contain spaces in the anchor e.g. <a href="link.html#this is the glossary">Link</a> Any ideas on what kind of regular expression I'd need to use to find the Spaces after the # and replace them with a - or _ ...

How to fix this regular expression?

Hi, i have a regular expression to remove certain parts from a URI. However it doesn't take into account multiple parts in a way that works :-). Can somebody assist? $regex = '~/{(.*?)}\*~' $uri = '/user/{action}/{id}*/{subAction}*'; $newuri = preg_replace($regex, '' , $uri); //$newuri = /user/ //Should be: $newuri = /user/{action}...

How to get multiple regex matches in Java?

How can I find all substrings that match a regex in Java? (Similar to Regex.Matches in .Net) ...

Eliminating multiple periods in sequence

...

Wrap URL within a string with a href tags using Coldfusion

I have a Coldfusion site that is pulling in a feed that contains urls. I have some control over the urls so I know they will always start with http://. I want to wrap those urls in a href tags so they are clickable but I'm having trouble figuring it out. Any info you guys could give me would be amazing. Eric ...

Detecting browser in ASP.NET using RegEx

I am trying to detect the browser in my C# code by comparing the UserAgent string with some regular expressions. By the way, in case you are wondering, the reason why I use this approach instead of simply using ASP.NET's HttpBrowserCapabilities object is because I have received a list of more than 200 regex that correspond to 200 browse...

Using regexp to evaluate search query

Is it possible to convert a properly formed (in terms of brackets) expression such as ((a and b) or c) and d into a Regex expression and use Java or another language's built-in engine with an input term such as ABCDE (case-insensitive...)? So far I've tried something along the lines of (b)(^.?)(a|e)* for the search b and (a or e) ...

RegEx to accept 6 or 7 and then only an additional 9 or 10 numbers.

tax V1 /([67]\d{10})|([67]\d{9})/ V2 /[67]\d{9,10}/ RegexBuddy highlights the second and third test records, but also portions of the first and last. 6777777777777777777 6777777777 7777777777 77777777777777 Is it possible to only match the exact matches? ...

Regex Matching Error

Hi Everyone, I am new to Python (I dont have any programming training either), so please keep that in mind as I ask my question. I am trying to search a retrieved webpage and find all links using a specified pattern. I have done this successfully in other scripts, but I am getting an error that says raise error, v # invalid express...

Regex search and replace where the replacement is a mod of the search term

i'm having a hard time finding a solution to this and am pretty sure that regex supports it. i just can't recall the name of the concept in the world of regex. i need to search and replace a string for a specific pattern but the patterns can be different and the replacement needs to "remember" what it's replacing. For example, say i ha...

Boost regex not working as expected in my code

I just started using Boost::regex today and am quite a novice in Regular Expressions too. I have been using "The Regulator" and Expresso to test my regex and seem satisfied with what I see there, but transferring that regex to boost, does not seem to do what I want it to do. Any pointers to help me a solution would be most welcome. As a ...

Help with SED syntax : unterminated `s' command

Edit: I'm using CYGWIN/GNU sed version 4.1.5 on windows Vista and I want a case insensitive search I want to use sed to replace inline, the following: c:\DEV\Suite\anything here --- blah 12 334 xxx zzzzz etc\Modules etc Edit: anything here --- blah 12 334 xxx zzzzz etc means anything could appear here. Sorry for omitting that. In...

Scalable Regex for English Numerals

I'm trying to create a regex to recognize English numerals, such as one, nineteen, twenty, one hundred and twenty two, et cetera, all the way to the millions. I want to reuse some parts of the regular expression, so the regex is being constructed by parts, like so: // replace <TAG> with the content of the variable ONE_DIGIT = (?:one|two...

Writing a Regular Expression for not including something.

How can I write a Regular Expression to match, a string which does not contain the underscore "_". ...