regex

Use Reg Expression to reformat image in RSS feed

I am creating some RSS feeds using PHP (5.2) from a MySQL db specifically for an iPhone app I am making through AppMakr. They are taken from articles on a website which contain images embedded in them, however in the feeds they don't look great. What I want to try and do is whenever there is an image surround it in <p> so they are on th...

BeautifulSoup or regex HTML table to data structure?

Hi, I've got an HTML table that I'm trying to parse the information from. However, some of the tables span multiple rows/columns, so what I would like to do is use something like BeautifulSoup to parse the table into some type of Python structure. I'm thinking of just using a list of lists so I would turn something like <tr> <td>1,1</...

Using PHP to parse Googlemaps

I have a site that I screen-scrape off GoogleMaps to get the driving distance from one point to another. It isn't heavily used (20 requests per week max), but Google's recent upgrade broke this functionality. I used to use this: $url = 'http://maps.google.com/maps?f=d&hl=en&saddr='.$start.'&daddr='.$finish.'&output=xml'; $ch = curl_...

Small Problem with Regular Expression when checking for character input

I have made a simple webpage to check for regular expressions. <html> <head> <script type="text/javascript"> var illegalChars = /^[&*%]+$/ function validate_form(thisform) { with (thisform) { if (illegalChars.test(regextest.value)==true) alert('Illegal Characters'); {regextest.focus();return false;} } } </script> </head...

python re: r'\b \$ \d+ \b' won't match 'aug 12, 2010 abc $123'

Hi, so i'm just making a script to collect $ values from a transaction log type file for line in sys.stdin: match = re.match( r'\b \$ (\d+) \b', line) if match is not None: for value in match.groups(): print value right now I'm just trying to print those values it would match a line containing $...

How do I replace the nth regex group with a new String in .net?

I have a pipe delimited string like this: blah|blah|blah|blah|blah|blah|blah|blah|blah|oldDate|blah|blah| I would like replace the content of the 10th section with a new Date. I am able to match the the old date with the the following code: 'create a group with the first 9 non-pipes followed by a pipe, a group with the old date follo...

c# regexp pattern to <id> .... </id>

I wrote the following pattern: @"<([0-9]+)>(.*?) < /$1>" but it doesn't work. how could i refer to the first group? source text: "Method()<0>int x = 0; while(x < 10)<1>echo(x)< /1>< /0>" ...

clojure equivalent for ruby's gsub

How do i do this in clojure "text".gsub(/(\d)([ap]m|oclock)\b/, '\1 \2') ...

Regular Expression to find hidden fields in html

I am looking for a regular expression to find all input fields of type hidden in html output. Anyone know an expression to do such? ...

What regex could I use to extract a body of XML text from a body of unformatted text?

Let's say I have the following body of text: Call me Ishmael. Some years ago- never mind how long precisely- having little or no money in my purse, and nothing particular to interest me on shore, I thought I would sail about a little and see the watery part of the world. It is <?xml version="1.0" encoding="utf-8"?> <RootElement xmln...

Boost Regex not playing welll with Snow leopard

So I inherited code written in C++ that uses the Boost library. I could compile (using Code Blocks) and run the code on Linux Ubuntu but when I ported it over to the mac and installed the boost library, I can compile it using code blocks (and specifying the location of the regex libraries) but it won't run. It just gives me the error: ...

RegEx pattern in .VB

I have a string and need a RegEx Pattern for this, so I can extract only the date and the numbers from the tags: Dim a as string= "<table id=table-1 > <tbody> <td align=right> <h2 id=date-one>12.09.2010</h2> </td> </tr> </tbody></table> <table id=table-2 border=0 cellspacing=0 cellpadding=0><tbody><tr><td align=center valign=middle><h3...

JavaScript Regex to Java Regex - Replace and Lambdas

What is the best way to approach translating this code into Java? (the section called Convert Alpha-numeric Phone Number to All Numeric) http://lawrence.ecorp.net/inet/samples/regexp-format.php Since Java doesn't have a lambda yet... what is the best approach for the String.replace ? ...

How to write the regex for this expression

I want to match strings like this: !! so I suppose the input have the right elements but whether the they are evaluable, that is left for the evaluator! 1+(2-3)*(4/5) what is the regex for matching this, something like this: ([0-9\+-\*\/\(\)]+)? but this seems not working. ...

how to replace the characters in strings with '#'s by using regex in Python

How can I replace the contents of strings with #'s in Python? Assume no comments, no multiple lines for one string. Like if there is a line in a python file: print 'Hello' + "her mom's shirt". This will be translated into: print '#####' + "###############". It's like a filter to deal with every line in a python file. ...

How can I add regular expressions to MySQL datafields?

I have the following table: Table Account{ [...] email varchar(100), [...] } and a corresponding regular expression: /^[A-Z0-9._%+-]+@[A-Z0-9.-]+\.[A-Z]{2,4}$/i How can I use the MySQL model, to link the regular expression to the the data-field "email", so that the regex is accessible to read out through php as well as ...

How to convert MySQL datatype names into regular expressions using php?

Is there a php function to get regular expressions able to check if an input fits a certain MySQL data type? In example: $foo = get_regex_for_data_type("int(10) unsigned"); echo $foo; would return something like: /^[0-9]{1,10}$/ ...

Regex to figure out a complex string.

I am trying to parse some text files into a database and there is a string that includes 2 pieces of information in it. There are a few options for what the string can look like. It can either look like a single word Word or it can have that first word, followed by a dash, followed by any number of other words like Word - Second. The key...

Can't match any of this subject with preg_match

I am trying to match some of the Javascript on a Youtube video page. The pattern thats the same for every video is like this: <param name=\"flashvars\" value=\"somethingsomethingsomething\"> I need to get out everything in value, in this case somethingsomethingsomething. It is commented out because this is embedded in Javascript. This...

Regex match everything but ...

Hi, I would like to create a regular expression to match every word, whitespace, punctuation and special characters in a string except for specific keywords or phrases. Because I only can modify regex, not server code I have to use match instead of replace. I have something like this so far: (?!(quick|brown|fox|the lazy))\b\w+ but it i...