regex

recursive nested expression in Python

I am using Python 2.6.4. I have a series of select statements in a text file and I need to extract the field names from each select query. This would be easy if some of the fields didn't use nested functions like to_char() etc. Given select statement fields that could have several nested parenthese like "ltrim(rtrim(to_char(base_fiel...

How can I extract field names from SQL with Perl?

I have a series of select statements in a text file and I need to extract the field names from each select query. This would be easy if some of the fields didn't use nested functions like to_char() etc. Given select statement fields that could have several nested parenthese like: ltrim(rtrim(to_char(base_field_name, format))) renamed_f...

regular expression to validate image filename

Heya im looking to validate a string and make sure it is the following format "thumb_*.jpg|gif|png" where * is a wildcard, and jpg|gif|png are optional file extensions this is in PHP Is that possible? ps: i just want return value true or false ...

Regex question - asp.net iis url rewrite

Could anyone help me with this regex issue? ^(Songs|Albums)$ becomes {R:1}.aspx This gives you songs.aspx, albums.aspx wondering if I can do this in Regex: ^(Songs|Albums|Songs/List)$ and how do I get SongsList.aspx from Songs/List? Thanks! Edit This worked: ^(Songs|Albums)/(List)?$ {R:1}{R:2}.aspx ...

How can I capture an escaped " but not an unescaped one?

Suppose the portion that needs to be captured by regex is indicated by PORTION in the following string ,"PORTION","","a",["some_string"] Examples of PORTION are \"abc123 abc123\" \"abc123\" abc\"123\" abc123 so the strings actually look like ,"\"abc123","","a",["some_string"] ,"abc123\" ","","a",["some_string"] "\"abc123\...

Regex for finding 'some' and replacing with 'xyz.some'

I need to write a regular expression in ruby for finding a string like 'some' and then replace it with say 'xyz.some'. How do I go about it? ...

Regular Expression to validate the field: Field Data should not contain brackets.

Hi all, [dbo].[Regex]('^[-a-zA-Z0-9,&''.@#/:;]+$',@ClaimantMailingAddressLine1) above is my regular expression when i am passing '(' or ')'brackets symbol it is nt returnig error... please hw 2 do this.... and please teach me how to eliminate perticular character is a invalid thing. rite now wt ever symbol is present in brackets i.e...

Manipulating Javascript RegExp results as non-strings

It's much easier to show the Javascript code than offer a complex explanation: var html = '<input tabindex="1" type="text">'; html.replace(/tabindex="([0-9]+)"/g, 'tabindex="' + ("$1" * i) + '"'); In this code, "$1" will always be a string, meaning this RegExp will always result in 'tabindex="NaN"' ... Using parseInt doesn't work. Is...

Regex to parse links containing specific words

Taking this thread a step further, can someone tell me what the difference is between these two regular expressions? They both seem to accomplish the same thing: pulling a link out of html. Expression 1: '/(https?://)?(www.)?([a-zA-Z0-9_%]*)\b.[a-z]{2,4}(.[a-z]{2})?((/[a-zA-Z0-9_%])+)?(.[a-z])?/' Expression 2: '/<a.*?href\s*=\s*["\'...

Get seleted text parent tag using regex C#

<SPAN id=spanD121C150D2 style="BACKGROUND-COLOR: antiquewhite" CategoryID="1" MessageID="2316" refSpan=""> <SPAN id=span1CE69EDE12 style="BACKGROUND-COLOR: blue" CategoryID="2" MessageID="2316" refSpan="">platnosci inny srodkiem platnosci. DC - zakup paliwa na stacji benzynowej 101-500 (150 zl). 27 </SPAN> </SPAN> I have a string ...

javascript Regex unicode help

in a JavaScript, i am using Regex to split(/\W+/) to words. when i split this, it's returning wrong value var s3 = "bardzo dziękuję"; s3 = s3.split(/\W+/); [0]: "bardzo" [1]: "dzi" [2]: "kuj" How to fix this problem? please advice ...

Using a "does not end with" regex for replacement purposes: how to avoid replacing the last character?

I'm using the following regular expression <a href="[^/] to find all links which do not start with a slash. I want to use the result of this regex to replace all <a href="somelink.html"> tags with something like <a href="http://mysite.com/somelink.html"&gt;. But the problem with my regular expression is that (in the above example) th...

regex expression logic

Regex expressions seems cocumbersome, they always drive me mad when trying to build it up. And i end up asking for help. But once i am given the result it looks really coool. Gurus, is there a way to go about it to break it up. ...

Javascript Regex to replace URLs with links, but not in embed (or img) tags

I'm currently using the following code, to search the a div on a page for URLs and replace them with a tags. However when we have a embed tags within the div it messes up the links within these tags. function replaceURLWithHTMLLinks(text) { return text.replace(/(ftp|http|https|file):\/\/[\S]+(\b|$)/gim,'<a href="$&" class="my_lin...

Regex to convert a space separated list to a SQL where clause

I'm almost embarassed, but I'm struggling to create a regular expression to change something like cat dog mouse to a SQL where clause: a.cat=b.cat AND a.dog=b.dog AND a.mouse=b.mouse With s/(\w*)\s?/a.$1=b.$1 AND / I get a.cat=b.cat AND a.dog=b.dog AND a.mouse=b.mouse AND a.=b. AND Ouch. Help appreciated. EDIT: I ended up usin...

JavaScript: dynamic regex for my own parser

I am trying a new direction in Language Kits (or whatever you want to call those multi language text files with placeholders). Basically, I have text like this: Hello, my name is %0. Welcome to %1!. This would be my pText. My pValues is an array whose values represent %0 and %1. The following function should find %0 and replace it with...

How to get a basic preg_match_all replacement for std::string in C++?

with "basic" is meant: Only the operators "+" (->following..) and "|" (->or) are needed. Prototype: preg_match_all(std::string pattern, std::string subject, std::vector<std::string> &matches) Usage Example: std::vector<std::string> matches; std::string pattern, subject; subject = "Some text with a lots of foo foo and " + char(255) ...

Replacing based on position in string (Regex)

Is there a way using regex to replace characters in a string based on position? For instance, one of my rewrite rules for a project I'm working on is "replace o with ö if o is the next to last vowel and even numbered (counting left to right)" So, an example is: heabatoik would become heabatöik (o is the next to last vowel, as well as ...

Searching for a » character in a JavaScript RegExp

How can I search for a » character in a JavaScript regexp? Code that's not working right now: var extralinks = new RegExp('»','g'); div.innerHTML = div.innerHTML.replace(extralinks,'This is special punctuation'); Grazie! ...

php/regex: separate feed data

<description>&lt;img src='http://example.com/Pic_018_70x70.gif'&amp;gt;&amp;lt;/img&amp;gt;&amp;lt;br /&gt;This is the content of the description.</description> If I have images coming in the description field of a feed, how can I separate the image into a variable and strip the noise and have the description left too? ...