regex

.Net Regex to parse Excel header / footer strings

I am trying to create a .Net Regex that will separate an Excel header data string into its component parts. The following example shows the format of the raw data string I need to parse: &LLeft-side text&CCenter text&RRight-side text The tags &L, &C and &R respectively demark the left, center and right sections of the header data. So,...

Property Editor not registered with the PropertyEditorManager error on Custom Validation Tag (java)

Hello, I am using TomCat 5.5 with MyFaces 1.1 and am trying to implement a custom regex validation tag. My RegExValidator class looks like this: public class RegExValidator implements Validator, StateHolder { private String regex; private boolean transientValue = false; public RegExValidator() { super(); } public RegE...

Formal language expressiveness of Perl patterns

Classical regular expressions are equivalent to finite automata. Most current implementations of "regular expressions" are not strictly speaking regular expressions but are more powerful. Some people have started using the term "pattern" rather than "regular expression" to be more accurate. What is the formal language classification of...

Text extraction from email in Python

My users will send me posts by email ala Posterous I'm using Google Apps Engine (GAE) to receive and parse emails. GAE returns the text part of the message. I need to extract the post from the plain text part of the message. The plain text can be "contaminated" with promotional headers, footers, signatures, etc. Also I would like to ...

Powershell regex question involving balancing parenthesis

Hi, How can I convert a table column definition into an array of columns using regex's without taking formatting into account? I'm confused how to split on "," as they can also appear in the datatype definition part (between matching parenthesis). Sample input: CREATE table test ( DISTRICT VARCHAR(3) CHARACTER SET LATIN NOT CASESPECIF...

Another tricky preg_match

Just need to see if a paragraph contains a "stop word", the stop words are in an array below. I had the formula as: $pattern_array = array("preheat", "minutes", "stir", "heat", "put", "beat", "bowl", "pan"); foreach ($pattern_array as $pattern) { if (preg_match('/'.$pattern.')/i', $paragraph)) { $stopwords = 1; ...

RegEx - Only one valid email

Hello, I know it's my fault and it is not complicated but I cannot find the answer by myself so I beg you to help me build this RegEx. I'm trying to avoid users to enter more than one email address by line, so I'd like to limit the "@" occurrences to only 1 and also check there are not commas (,).... Here's a simplified version of the ...

Regular Expression search/replace help needed, Python

One rule that I need is that if the last vowel (aeiou) of a string is before a character from the set ('t','k','s','tk'), then a : needs to be added right after the vowel. So, in Python if I have the string "orchestras" I need a rule that will turn it into "orchestra:s" edit: The (t, k, s, tk) would be the final character(s) in the str...

With PHP filter a textfile into an A-Z listing

I have a text file that reads: 9123 Bellvue Court 5931 Walnut Creek rd. Andrew Bailey Chris Drew Earl Fred Gerald Henry Ida Jake Koman Larry Manny Nomar Omar Perry Quest Raphael State Telleman Uruvian Vixan Whales Xavier Yellow Zebra What I need to do is I need to create a A-Z listing... so: # A B C D E F G H I J K L M N O P Q R S T ...

Grep and regular expression

I need some way to find words that contain any combination of characters and digits but exactly 4 digits only. EXAMPLE: a1a1a1a1 //OK 1234 // Not a1a1a1a1a1 Not ...

regex negation question

Hi, Does anybody know how to code a regular expression (for use with some grep like tool) which will search for the word 'vat' but exclude the word 'pri**vat**e'. I've taken over a project which has hundreds of references to VAT (some hard-coded, some not) and as the VAT rate in the UK is changing on January 1 I need to update the proj...

Replace strings using regular expressions and backreferences in Clojure

I'm trying to convert from HTML to Latex, and want to change this: <a href="www.foo.com/bar">baz</a> into: baz\footnote{www.foo.com/bar} I'd like to generate a Clojure function to take a chunk of text, and replace as many matches as exist in a given paragraph. I've tried (.replaceAll "<a href=\"foo.com\">baz</a>" "<a.*h...

Find all links in a string and transform them into anchor tags using PHP.

http://stackoverflow.com should become <a href="http://stackoverflow.com"&gt;http://stackoverflow.com&lt;/a&gt; EDIT: It would be great if anchor tags from the original string stayed intact. ...

Ways to share regex across DataAnnotations /Attributes

I am playing around with the System.ComponentModel.DataAnnotations namespace, with a view to getting some validation going on my ASP.NET MVC application. I have already hit an issue with the RegularExpression annotation. Because these annotations are attributes they require constant expressions. OK, I can use a class filled with regex...

301 redirection help on wordpress

Hello all friends, I'm searching for a 301 redirect rules in .htaccess for the last one week. I have visited many similar pages here too. But all are not working for me. So I'm asking help from masters like you. I'm using wordpress blogging platform. Before I was using Joomla and that time so many 404 errors was there on my website. T...

How do I extract words from a comma-delimited string in Perl?

Hi. I have a line: $myline = 'ca,cb,cc,cd,ce'; I need to match ca into $1, cb into $2, etc.. Unfortunately $myline =~ /(?:(\w+),?)+/; doesn't work. With pcretest it only matches 'ce' into $1. How to do it right? Do I need to put it into the while loop? Thanks! ...

How to find this regex using PHP

find all the <1></1> and <2></2> and <3></3>... in a string. ...

Regex with vb.net

Hi, I have the following html contained in a string. <tr>    <td>Hello</td> </tr> <tr>    <td>World</td> </tr> <tr>    <td>lets all smile</td> </tr> I would like to use RegEx to find the <tr></tr> that contains the text "World". The difficulty is that there might be other <td> around the one that contains the search text....

Qt4 compatible RegExp for URL highlighting

I'd like to automatically highlight and extract URLs from a QWebView or QTextEdit. I've found a lot of RegEx examples on the web which allows to do just that, but most of them seem overly complicated, don't work properly or are not compatible with Qt4's RegExp implementation. So I'm asking here for a Qt4-specific RegExp pattern which al...

Java: Regex replacing

Hi, I have this String: foo bar 567 baz Now I want to add before each number the String num:. So the result has to be: foo bar num:567 baz Also this has to work: foo 73761 barbazboom!! 87 result: foo num:73761 barbazboom!! num:87 The regex to search number is this: [0-9]+ But I want to replace the matching substring with num: +...