regex

How to get this regular expression to match </span>

This is the sort of HTML string I will be performing matches on: <span class="q1">+12 Spell Power and +10 Hit Rating</span> I want to get +12 Spell Power and +10 Hit Rating out of the above HTML. This is the code I wrote: preg_match('/<span class="q1">(.*)<\/span>/', $gem, $match); But due to <\/span> it's escaping the / in </span>...

preg_replace with parentheses

In PHP my string looks like this: "{{edit(3)}}". I would like the result to be: "open3close", using preg_replace or another method. Any ideas? ...

What's wrong with JavaScript's regular expression notation?

I was reading Douglas Crockford's web page, JavaScript: The World's Most Misunderstood Programming Language, and I couldn't help but notice that, under Design Errors, he mentions "the notation for literal regular expressions." What exactly is he talking about? What's wrong with JavaScript's notation for regular expressions, and why? ...

twitter regex for displaying text as url but not if it is meant as text

Hi, Can someone help me to tweak this regex?? I have this regex for twitter and if I spell a word like this R@chard, it wants to turn it in an URL. On Twitter itself it is displayed correctly. Erasing the last line is maybe obvious, although I don't know much about forming regex expressions. Maybe there is also a smarter one for use w...

Java - Regex for the given string

I have the following html code segment: <br> Date: 2010-06-20, 1:37AM PDT<br> <br> Daddy: <a href="...">www.google.com</a> <br> I want to extract Date: 2010-06-20, 1:37AM PDT and Daddy: <a href="...">www.google.com</a> with the help of java regex. So what regex I should use? ...

php regex , preg_match , extract url

I need to extract the first URL from some content. The content may be like this ({items:[{url:"http://cincinnati.ebayclassifieds.com/",name:"Cincinnati"},{url:"http://dayton.ebayclassifieds.com/",name:"Dayton"}],error:null}); or may contain only a link ({items:[{url:"http://portlandor.ebayclassifieds.com/",name:"Portland (OR)"}],er...

Problem using jQuery calculation with European-formatted numbers

I am calculating rows with a total with the jQuery.Calculation plugin but the total is ignoring everything after the decimal symbol. I suspect the fix lies in the regex but I can't figure out where. The following method should set the default correct for European decimals, it works pr row but the sum method for the calculation is ignori...

regex number problem

this is my regex for digital dnumbers: \d+(.\d+)+(,\d+) but now i have problem that number 3 or 30 are not valid any more. What must be my regex that also number 3 and 40 will pass. Thx ...

single split or match regex

9.jul. 3 dni od 205,00 EUR Is it possible with single regex (match opr split) get 205,00 number from string? It must be single regex and not 2 or 3 regex which give 205,00 as result. string looks like: <option value="9.7.2010|3">9.jul. 3 dni od 205,00&nbsp;EUR <option value="23.7.2010|3">23.jul. 3 dni od 205,00&nbsp;EUR <option valu...

Extract part from URL for a query string

I need a certain part of a URL extracted. Example: http://www.domain.com/blog/entry-title/?standalone=1 is the given URL. blog/entry-title should be extracted. However, the extraction should also work with http://www.domain.com/index.php/blog/[…]as the given URL. This code is for a Content Management System. What I've already com...

constants and mysql, best practices

Hello, I currently have a list of defined constants and a function that regex'es every pulled MySQL string and looks for things like CLIENT_NAME, LOCAL_API_ADDRESS and auto-changes it. // several fields define ('CLIENT_NAME', '...'); define ('LOCAL_API_ADDRESS', '...'); ... The thing is, as my app is getting larger I feel this is pre...

Regular Expressions in match attribute

Hello. I just want to know if it's possible to use regular expressions in the match attribute of the template element. For example , suppose i have the follow xml document: <greeting> <aaa>Hello</aaa> <bbb>Good</bbb> <ccc>Excellent</ccc> <dddline>Line</dddline> </greeting> Now the xslt to transform the above document:...

escaping MSWord style quotes in a RegExp

I need to convert strings pasted into a text area so that, if they were pasted from MS Word, the weird quotation marks and apostrophes that Word likes to use will get converted to regular single and double quotes. Unfortunately my text editor seems to already convert such quotes when I save, so any regular expression I make seems to get...

Lazy regex doesn't work as expected C#

Hello. I have the following regex: a?\W*?b and I have a string ,.! ,b When searching for a match I get ,.! ,b, but not just b as I expect. Why is that? How to modify the regex to get what I need? Thank you for your help. ...

Regular Expression: 0-9 A-Z a-z or any of these '!#$%&'*+-/=?^_`{|}~.

Hi, I need to regex string myString to only have: 0-9 A-Z or a-z any of these characters '!#$%&'*+-/=?^_`{|}~. This is my code line: new Regex("[a-zA-Z0-9]").IsMatch(myString); So far I have [a-zA-Z0-9] and this works fine for the first two listitems. Currently tearing my hair out (and it's so nice I want to keep it) over metacha...

Regular expression wrong matches

I have been using the following regular expression in ASP.NET and Javascript: [a-zA-ZöäüÖÄÜß0-9]{1}[a-zA-ZöäüÖÄÜß0-9_.\-]{2,14}[a-zA-ZöäüÖÄÜß0-9.!]{1} Now, I am migrating to ASP.NET MVC and I am checking my code. I find that 'test' %test Are also matches. That's probably because not the whole string needs to be matched. And the te...

simplify my multiline regex - match plus next x amount of lines

I have the following Haml code: %ul#sub-nav %li.li1 %a{:href => "/dsadasd/"} dasdasd %li.li2 %a.selected{:href => "/asdadasd"} Tasdada /asdas %li.li3 %a{:href => "/dasd/"} asdasd %li.li4 %a{:href => "/wdasn/"} das I seem to be able to match this with the following repetitive rege...

TextMate: Regex replacing $1 with following 0.

Hi, I'm trying to fix a file full of 1- and 2-digit numbers to make them all 2 digits long. The file is of the form: 10,5,2 2,4,5 7,7,12 ... I've managed to match the problem numbers with: (^|,)(\d)(,|$) All I want to do now is replace the offending string with: ${1}0$2$3 but TextMate gives me: 10${1}05,2 Any ideas? Thank...

PHP Regular Expression syntax

I have a number of exported text fields from an old access database that are being ported over into a new mysql structure. There are various field inputs in the format: 10/06/2010 09:10:40 Work not yet started I would like to take that string and use some sort of regular expression to extract the date/time information and then the com...

How can I grep these lines

I want to grep lines starting with a @ and also lines starting with // followed by a line starting with @ Example: //text1 @text2 text3 result: //text1 @text2 How can I do this with grep or any other basic unix tool? ...