regex

Could someone help me parse this string with regex?

I'm not very good with regex, but here's what I got (the string to parse and the regex are on this page) http://rubular.com/r/iIIYDHkwVF It just needs to match that exact test string ...

List of Python regular expressions for a newbie?!

Hi! I recently learned a little Python and I couldnt find a good list of the RegEx's (don't know if that is the correct plural tense...) with complete explanations even a rookie will understand :) Anybody know a such list? ...

Regex for HTML with java.util.regex

I need a regex for following html : <div xmlns="http://www.w3.org/1999/xhtml"&gt; <p/> <p/><p/> <p/> </div> This comes form a richtext field and obviously this is no meaningful content or means: empty. I can not say in java: if (richTextConent == null || richTextContent.length == 0) because the richtext field contains somethin...

Simulate php array language construct or parse with regexp?

From an external source I'm getting strings like array(1,2,3) but also a larger arrays like array("a", "b", "c", array("1", "2", array("A", "B")), array("3", "4"), "d") I need them to be an actual array in php. I know I could use eval but since it are untrusted sources I'd rather not do that. I also have no control of the external...

Validate Email Header in Python

I have a RegEx for validating email addresses, but I'm really looking to validate a whole From header. Any of these would be valid: [email protected] <[email protected]> My Name <[email protected]> Is there anything out there that would validate these as valid from headers? I'm going to look in the smtp library :) ...

Getting rid of multiple periods in a filename using RegEx

Hello! I have an application that requires me to "clean" "dirty" filenames. I was wondering if anybody knew how to handle files that are named like: 1.0.1.21 -- Confidential...doc or Accounting.Files.doc Basically there's no guarantee that the periods will be in the same place for every file name. I was hoping to recurse through a...

Perl regex using negative look? can't seem to figure out how to do this properly

I'm trying to get this to work with perl's regex but can't seem to figure it out.. I want to grab any url that has ".website." in it, except ones that are like this (with "en" preceding ".website." $linkhtml = 'http://en.search.website.com/?q=beach&amp;' ; This is an example of a url that I would want to be returned by the regex, ...

regex to split line (csv file)

I am not good in regex. Can some one help me out to write regex for me? I may have values like this while reading csv file. "Artist,Name",Album,12-SCS "val""u,e1",value2,value3 Output: Artist,Name Album 12-SCS Val"u,e1 Value2 Value3 Update: I like idea using Oledb provider. We do have file upload control on the web page, th...

Regular expression only returning one match

This regular expression is only returning one match. (I'm looking to retrieve all image sources/locations (such as 'folder/image.png' contained in the src attribute in the img html tag). Sample input string: input = @"<p>here is an image</p><img attr=""ahwer"" src=""~/Images/logo.png"" st=""abc""/><p>some more text here</p>"; ...

How can I strip escape codes from a string in Perl?

The original string is passed as: FileSystems\/\1K-blocks=5036316, FileSystems\/\Available=3295944, FileSystems\/\Filesystem=/dev/cciss/c0d0p2, FileSystems\/\Use%=32% What I need as an output is: / 1K-blocks=5036316, / Available=3295944, / Filesystem=/dev/cciss/c0d0p2, / Use%=32% but trying to delete the '\' with a regex is giving ...

Perl: using variable in substitution

Possible Duplicate: How to use a variable in the replacement side of the Perl substitution operator? I would like to do something like $sub = "\\1"; $match = "hi(.*)"; $str = "hi1234" $res = $str; $res =~ s/$match/$sub/g I would like this to return 1234 but in this case it returns \1. I.e. I want it to be equivalent to s/$m...

preg_match_all: Why would "this" match but "that" won't?

So, I'm basically trying to match anything inside (and including) object tags, with this: <?php preg_match_all('/<object(.*)<\/object>/', $blah, $blahBlah); ?> It finds a match for this: <object classid="clsid:d27cdb6e-ae6d-11cf-96b8-444553540000" width="400" height="250" codebase="http://download.macromedia.com/pub/shockwave/cabs/fl...

JavaScript RegEx to determine the email's domain (yahoo.com for example)

With JavaScript I want to take a input 1st validate that the email is valid (I solved for this) 2nd, validate that the email address came from yahoo.com Anyone know of a Regex that will deliver the domain? thxs ...

What's wrong with this awk regex replacement?

I have a peculiar problem replacing some text in an xml file using awk regex matching. The xml files are simple. There's a paragraph of text in the node of each xml and the awk program replaces this text with another paragraph of text picked from the text file rtxt. But for some reason the text in rtxt (labeled '42') that substitutes t...

A href catching

Hello, I'm using BeautifulSoup for parsing some html. Here is the content: <tr> <th>Your provider:</th> <td> <img src="/isp_logos/la-la-la.ico" alt=""/> <a href="/isp/SomeProvider"> Provider name </a> &nbsp; <a href="http://*/isp-comparer/?isp=000000"&gt; </a> </td> </tr> I have to get SomeProvider text from the link . ...

regex to find tag id and content JavaScript

Hey I'm trying to do something quite specific with regex in javascript and my regexp-foo is shakey at best. Wondered if there were any pros out there who could point me in the right direction. So I have some text... <item id="myid1">myitem1</item> <item id="myid2">myitem2</item> ...etc And I would like to strip it out into an array t...

validates_format_of to exclude certain patterns

I want a rails model to exclude certain patterns: runs of two or more spaces. User.name = "Harry Junior Potter" is valid, but User.name = "Harry Junior Potter" is not (two spaces between Harry and Junior). This to avoid identity theft, where those two names are displayed the same (HTML compresses runs of whitespace). In other words:...

Regex that checks upper or lower case characters with or without accents.

How can I make the following regular expression ignore all whitespaces? $foo = ereg_replace("[^áéíóúÁÉÍÓÚñÑa-zA-Z]", "", $_REQUEST["bar"]); Input: Ingeniería Eléctrica'*;<42 Current Output: IngenieríaEléctrica Desired Output: Ingeniería Eléctrica I tried adding /s \s\s* \s+ /\s+/ \/s /t /r among others and they all failed. Objec...

Apache Rewrite Rule (Regex)

Hello fellow programmers, I'm using apache and i need to rewrite URL of type: /a/b/c/d/boundary/stuff* to: /boundary/a_b_c_d/stuff* I need to rewrite the first Uri to the second format. The number of elements before '/boundary' are variable and i want to replace all slashes('/') between elements by '_' The boundary word is...

Perl splitting text string (from HTML page, text document, etc.) by line into array?

This is kind of a weird question, at least for me, as I don't exactly understand what is fully involved in this. Basically, I have been doing this process where I save a scraped document (such as a web page) to a .txt file. Then I can easily use Perl to read this file and put each line into an array. However, it is not doing this base...