regex

Regular Expression - extract digits

I have strings of text that may have the following formats: Was £39.95 Now Only £29.00 OR Was 0.95p Now 10p What is the easiest way to extract two numbers from each string, so I can subtract them later. ...

jQuery RegEx Problems

Possible Duplicate: jQuery find/replace without changing original text I have the following RegEx but I am getting a JS error RegEx: $("#construct_version").html( new RegExp("(" + selection + ")", "g"), $("$1").wrap(childElements[child])); JS Error: Uncaught Syntax error, unrecognized expression: $1 This questions ...

What is wrong with this regex?

I have the following string: <?php $string = '<meta name="Keywords" lang="fr" content="ecole commerce, apres bac, ecole management, ecole de management, écoles de commerce, école de management, classement ecole de commerce, ecole commerce paris, ecole superieure de commerce, concours ecole commerce, hec, esc, prepa, forum ecole comm...

Getting portion of href attribute using hpricot

I think I need a combo of hpricot and regex here. I need to search for 'a' tags with an 'href' attribute that starts with 'abc/', and returns the text following that until the next forward slash '/'. So, given: <a href="/abc/12345/xyz123/">One</a> <a href="/abc/67890/xyzabc/">Two</a> I need to get back: '12345' and '67890' Can anyo...

How can I build a regular expression to match a single word?

Hi, Say I had the following strings: Dublin, Ireland. DublinIreland Ireland, Dublin What regular Expression could I use to find the word Dublin in the above strings, but, it cannot count DublinIreland. As in, DublinIreland doesn't say Dublin, it is a whole word that says DublinIreland. Sorry I edited the question. First one was as...

javascript regular expression for pretty formatting user text

Hello I am doing a research here to find you the best way to format user text messages. A sample of what I am trying to achieve: 1) user sends this message: Doctor, I would like to have an appointment tomorrow morning.Please,call me! 2) my application formats this text outputting this: Doctor, I would like to have an appo...

Finding everything but anchor tags within a <p> tag with regex

I have several HTML blocks on a page set up like: <p class="something"> <a href="http://example.com/9999"&gt;text 1 2 3</a> <a href="http://example.com/2346saasdf"&gt;text 3 4 5</a> (9999) <a href="http://example.com/sad3ws"&gt;text 5 6 7random</a> </p> I want to get the digit that is in the parentheses, with them. I h...

Convert ReGex to a simple and fast function (comma stripping from a JSON string)

Hi! I have this ReGex expression in JavaScript right now: /(.*)(,)([\]\}]+)$/.exec(stringData). Basically it's removing any trailing comma from a malformed JSON string, (by concatenating r[1] + r[3] you get it). It's working well except it's way too slow on big strings. So a regex is not a good choice here. I would like to convert this ...

Maximum match length of a regular expression

What is the easiest way to determine the maximum match length of a regular expression? Specifically, I am using Python's re module. E.g. for foo((bar){2,3}|potato) it would be 12. Obviously, regexes using operators like * and + have theoretically unbounded match lengths; in those cases returning an error or something is fine. Giving a...

How to make up a regexp that matches all files in the directory except for files with .jar extension?

Let's assume that we have the next directory structure: /parentdir/ /childdir/ child_file1.txt child_file2.jar file1.txt file2.txt so, we get next full file names: /parentdir/file1.txt /parentdir/file2.txt /parentdir/childdir/child_file1.txt /parentdir/childdir/child_file2.jar Which regular expression matche...

need to modify this Regex to not remove a character

I have the following regexp (/\?(.*?)\&/) which when I use it in the following javascript code it removes the "?" from the replacement result. href=href.replace((/\?(.*?)\&/),"") The beginning href value is this... /ShoppingCart.asp?ProductCode=238HOSE&CouponCode=test I get this as my result right now... /ShoppingCart.aspCouponCod...

Regex to slect a string not having a certain word followed by a certain set of words

I am trying to find a regex that will do the following Return true if a string ends with jaxws.managed but does not contain delegate. eg abc/delegate/xyz/jaxws/managed should return false, while abc/def/xyz/jaxws/managed should return true I tried using the regex ([^(delegate)])+([a-z]*[\\/]jaxws[\\/]managed[\\/])+ but it fails...

Regular Expression; extracting numbers from strings with the equals sign as the delimiter

How can I extract the decimal part of a string that has an equals sign as the delimiter? Example: 2 = No 10 = (6 - 8 hrs/day, Good & Restful) 1 = low in fat 1 = low in sugar 1 = high in fiber Someone please help. Thanks. ...

Resize embed code PHP

Can I automatically resize an embed code efficiently using PHP (maybe with regex?) Here's an example of the embed code: <object width="500" height="350"> <param name="movie" value="http://www.megavideo.com/v/"&gt;&lt;/param&gt; <param name="allowFullScreen" value="true"></param> <embed src="http://www.megavideo.com/v/" type...

How to select art-8, but not cart-8 with javascript.

I have the following if statement in javascript. I am targeting pages which have art-8 in url. Sample url is like this, http://www.mywebsite.com/art-8.asp?id=435&amp;iPageID=43 However this will pick up an url with cart-8 and I don't want that. I want only select art-8 in url not cart-8. How should I change it? if (location.pathnam...