regex

Replacing with SED, trying to append content doesn't work

I'm trying to use sed to fix a file, and I'm having trouble grokking what I'm doing wrong. Any pointers on why sed isn't behaving as I expect it to would be appreciated. My file consists of a bunch of lines, each containing a single value. The content of the values is irrelevant for the replacing, save that they're always alpha-numeric ...

Java Regex Problem

Hello, I have a string that i am trying to extract patterns from, the string is as follows: ( ELT2N ( ELTOK wpSA910 wpSA909 wpSA908 wpSA474 ) ) The problem is, i dont know how many of the strings beginning with 'wp' will be in the string i am trying to search, however i want toi extract all of them using one statement. I am currentl...

RegEx: how to find whether a text begins with currency symbols ?

Hi, I would like to check whether a given text begins with some currency symbols, like $€£¥. how to achieve that using regex ...

How can I catch the following obfuscated email addresses in PHP?

Consider the following script that contains obfuscated email addresses, and a function that attempts to replace them based with ***** by using regex pattern matching. My script attempts to catch the words: "at", "a t", "a.t", "@" followed by some text (any domain name), followed by "dot" "." "d.o.t", followed by a TLD. Input: $str[] = ...

Regex match this OR that?

What is the regex for this? Match if string NOT ( ends in .php OR ends in .html OR contains / ) Thank you! Edit: I need the NOT part because the expression is to be used on an Apache mod rewrite, since I can't change the logic of mod _rewrite to avoid the NOT. Edit: My initial effort was ([^/]+)(.html)$(^.php)$ -- which is...

python -- re.match vs. re.search

I have recently been jumping into understanding regex with python. I have been looking at the api; I can't seem to understand the difference between: re.match vs. re.search when is it best to use each of these? pros? cons? Please and thank you. ...

regex exclude match from capture

Using Regex in .Net I will have a set of data that comes in something like this < Bunch o' Data Here > where < is just the indicator of a new record and > is the end of the record. these records may come in like this < Dataset 1><Dataset 2 broken, no closing tag <dataset 3> they could also come in as < Dataset 1>Dataset 2 broke...

How do i remove &#x2002; &#x2014; &#x2013; special characters from my XML files

this is a sample of the xml file <row tnote="0"> <entry namest="col2" nameend="col4" us="none" emph="bld"><blst> <li><text>Single, head of household, or qualifying widow(er)&#x2014;$55,000</text></li> <li><text>Married filing jointly&#x2014;$115,000</text></li> </blst></entry> <entry colname="col6" ldr="1" valign="middle">&#x2002;</entr...

Regex - Capturing a number if a match exists

I'm looking to capture just the number after vspace. How would you do that in regex? Here is a sample string. <img align="left" alt="dude its me" border="10" height="168" hspace="30" vspace="10" width="130" /> So the end result would be 10 ...

Match everything that isn't a number followed by a letter

Apologies if this was answered elsewhere -- I did some searching and couldn't find the answer. Suppose I have a text file that contains a bunch of content. In that content is an occupation code, which is always in the format of a number followed by a capital letter. How can I extract ONLY the occ codes from the file? In plain english...

Objective-c regex to check phone number

How to validate a phone number (NSString *) in objective-c? Rules: minimum 7 digits maximum 10 digits the first digit must be 2, 3, 5, 6, 8 or 9 Thanks ...

Converting PCRE recursive regex pattern to .NET balancing groups definition

PCRE has a feature called recursive pattern, which can be used to match nested subgroups. For example, consider the "grammar" Q -> \w | '[' A ';' Q* ','? Q* ']' | '<' A '>' A -> (Q | ',')* // to match ^A$. It can be done in PCRE with the pattern ^((?:,|(\w|\[(?1);(?2)*,?(?2)*\]|<(?1)>))*)$ (Example test case: http://www.ideone.com/...

Check currency field only contains 1 fullstop

hi can someone please help me to compose a regular expression to check a currency string is in a particular format - 300.00 It can have only numbers both before and after the '.'. However i want only one occurrance of the '.'. Hence 300.00. or 300.0.0 is invalid. regards ...

ASP.NET MVC 2 Data Validation: Make C# Regex work for both C# and JavaScript simultaneously?

I have this C# regex: ^\s?((?<qty>\d+)\s?/)?\s?[$]?\s?(?<price>\d{0,2}(?:\.\d{1,2})?)\s?$ and use MVC's data validation at the client. JavaScript says this regex is invalid, although C# works perfectly fine. Any idea how to get it to work for both C# and JavaScript, since it doesn't seem possible to provide a separate JavaScript Reg...

Regexp to normalise (pad with zeroes) IP addresses

Hi, I have a copy of a log file I want to make easier to view/edit. I use textpad to remove stuff I do not want and I can enter a regular expression as search term and use \1.\2.\3.\4 in the target field for captured groups. I would like to change all IP addresses which start each line from [0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,...

How to define regular expression patterns like {min,max} repeats in SSMS or VS "Find and Replace" ?

I knew that we have something like this in regular expression syntax world. *The syntax is {min,max}, where min is a positive integer number indicating the minimum number of matches, and max is an integer equal to or greater than min indicating the maximum number of matches. So {0,} is the same as , and {1,} is the same as + http://ww...

Python string match

If a string contains *SUBJECT123 how to determine that the string has subject in it in python ...

regular expression: Find url from anchor tag

hi to all, i have problem . i want to find out the url form acnchor tag which consist "title" tag in anchor tag. example: <a href="http://www.test.com" title="xyz">this is test</a> how can i match the string and fetch url using regular expression. thanks ...

How to invert the forecolor and backcolor when any one of them changes

I am using a ajaxtoolkit to choose a color. I want to set the forecolor of the text as the reverse of backcolor. if a black has been choosen as backcolor then its corresponding forecolor should be set to white and vice versa. I want to do this with javascript <script type="text/javascript"> function colorChanged(sender) { // ...

Regex to change attribute order in a JSON string?

Using Facebook Search API, I got an response like: "data" : [ { "created_time" : "2010-07-24T19:47:31+0000", "description" : "...", "icon" : "...", "id" : "1", "link" : "...", "name" : "...", "type" : "link", "updated_time" : "2010-07-24T19:47:31+0000" }, { ...