regex

How to seperate Numbers from Symbols? regular expression???

hi, I am trying to seperate numbers from a string which includes %,/,etc for eg (%2459348?:, or :2434545/%). How can i seperate it, in VB.net ...

Find and Insert

I have a string that looks like (the * is literal): clp*(seven digits)1* I want to change it so that it looks like: clp*(seven digits)(space)(space)1* I'm working in C# and built my search pattern like this: Regex regAddSpaces = new Regex(@"CLP\*.......1\*"); I'm not sure how to tell regex to keep the first 11 characters, add tw...

Slow regex in Python?

I'm trying to match these kinds of strings {@csm.foo.bar} without matching any of these {@[email protected]} {@csm.foo.bar-42} The regex I use is r"\{@csm.((?:[a-zA-Z0-9_]+\.?)+)\}" It gets dog slow if the string contains multiple matches. Why? It runs very fast if I take away the brace matching, like this r"@csm.((?:...

Regular Expression for Parsing Hashtags in Java

I realize there are a couple of questions on this on the site, but none of them actually do a great job. They miss on some pretty typical use cases. Here is the Twitter message I am trying to parse (as you can see, some of these are not tags, just part of URLs, etc.): #anothertag Arrogance and bad PR http://www.adobe.com/index.html#anch...

Using Regexp to replace math expression inside Latex File

Hello, I am trying to replace characters inside a math environment with their boldface versions. Unfortunately, these characters occur inside the rest of the text, as well. My text: text text text text Gtext G G text .... \begin{align} f&=gG \\ G &= tG \end{align} text textG text $G$ text. Every G inside \begin{align} \end{a...

RegEx to modify urls in htmlText as3

Hi, I have some html text that I set into a TextField in flash. I want to highlight links ( either in a different colour, either just by using underline and make sure the link target is set to "_blank". I am really bad at RegEx. I found a handy expression on RegExr : </?\w+((\s+\w+(\s*=\s*(?:".*?"|'.*?'|[^'">\s]+))?)+\s*|\s*)/?> b...

How do I decipher a dynamic URL magic in Django

url(r'^([a-zA-Z0-9/_-]+):p:(?P<sku>[a-zA-Z0-9_-]+)/$', 'product_display', name='product_display'), url(r'^(?P<path>[a-zA-Z0-9/_-]+)$', 'collection_display', name='collection_display'), That's my current regex: My problem is this: I want to be able to match the product_display's regex without using :p: in the regex. I can do this by pu...

PCRE to replace #334455 hex with #345

I'm writing a function that replaces long hex coded color (#334455) with short one (#345). This can be only done when each color in hex is multiple of 17 (each hex pair consists of the same characters). e.g. #EEFFCC is replaced with #EFC, but #EDFFCC isn't replaced with anything. I want to make this with single preg_replace() call with...

Replacing leading and trailing hyphens with spaces?

What is the best way to replace each occurrence of a leading or trailing hyphen with a space? For example, I want ---ab---c-def-- to become 000ab---c-def00 (where the zeros are spaces) I'm trying to do this in Python, but I can't seem to come up with a regex that will do the substitution. I'm wondering if there is another, better wa...

Apache Mod Rewrite - Replace : character with another

I'm trying to rewrite all URL's that contain a ':' in it to another character. http://en.wikipedia.org/wiki/Filename#Reserved%5Fcharacters%5Fand%5Fwords Example: http://example.com/some_interesting:info http://example.com/some_interesting_info http://example.com/some:interesting:info http://example.com/some:interesting_info would al...

match unescaped characters in php

Hi, i need a regexp to match only single / in a string in PHP. "bla bla bla/bla bla bla" //The regexp must match the / character "bla bla // bla bla / bla bla" //The regexp must match only the last / not the first beacuse it is followed by another / so i want only unescaped /. ...

Replace an XML element's value? Sed regular expression?

I want to take an XML file and replace an element's value. For example if my XML file looks like this: <abc> <xyz>original</xyz> </abc> I want to replace the xyz element's original value, whatever it may be, with another string so that the resulting file looks like this: <abc> <xyz>replacement</xyz> </abc> How would you do...

what can be the regex for the following string

I am doing this in groovy. Input: hip_abc_batch hip_ndnh_4_abc_copy_from_stgig abc_copy_from_stgig hiv_daiv_batch hip_a_de_copy_from_staging abc_a_de_copy_from_staging I want to get the last column. basically anything that starts with abc_. I tried the following regex (works for second line but not second. \abc_.*\ but that ...

Regular Expressions _# at end of string

I am using the REGEXP_LIKE function in Oracle 10g to find values in a column with a suffix of _#(like _1, _2 etc). I can find _# in any part of the value with the query below but can I return only values with _# at the end ? SELECT * FROM Table WHERE REGEXP_LIKE (COLUMN,'_[[:digit:]]') ...

UrlRewritingNet Regex Required

I am trying to use URLRewritingNet to rewrite a website. The entire website is built using physical .aspx pages, and all I require is for them to show up as extensionless. I figured out the extensionless part and all of my root files work fine (~/default.aspx. ~/contact.aspx, etc). The problem comes when I have a physical file in a ph...

What kind of notation is this?

I've a string which looks like this: [{text:"key 1",value:"value 1"},{text:"key 2",value:"value 2"},{text:"key 3",value:"value 3"}] I'm not sure what kind of notation this is, AFAIK this is generated by a ASP .NET backend. It looks a lot similar to JSON but calling json_decode() on this fails. Can someone bring me some light on this ...

Convert an Extended Regular expression to .NET compatible RegEx

I've got a RegEx that works great on *NIX systems and languages that support Extended Regular Expressions (ERE). I haven't found a freely available library for .NET that supports ERE's, nor have I had any lucky trying to translate this into a non-ERE and get the same result. Here is the RegEx: ^\+(<{7} \.|={7}$|>{7} \.) Background: th...

Regular expression transformation for wiki-like mark-up

Consider the following mark-up input: * Line 1 * Line 2 :* Line 2.1 :* Line 2.2 * Line 3 This is typically coded as: <ul> <li>Line 1</li> <li>Line 2</li> <ul> <li>Line 2.1</li> <li>Line 2.2</li> </ul> <li>Line 3</li> </ul> My questions: What would be a good representation for the same input u...

simple regex -- replace underscore with a space

Hey, I'm writing my first Rails app, and I'm trying to replace the underscores form an incoming id name with spaces, like this: before: test_string after: test string How can I do this? Sorry if this is a bit of a dumb question, I'm not very familiar with regular expressions... ...

Regex to replace string1 with string2 except within html tags, OR as part of a url(outside of html)

I have a need to perform search and replace operations on large blocks of HTML. I do not wish to change anything that is part of an html tag (like urls) - I also do not wish to change urls OUTSIDE of html tags. I have a partial solution for matching a word that is not inside of html (src): word(?!([^<]+)?>) while regex buddy also say...