regex

Capture the last occurrence of a tag

My text is of the form: <Story> <Sentence id="1"> some text </Sentence> <Sentence id="2"> some text </Sentence> <Sentence id="3"> some text </Sentence> My task is to insert a closing tag </Story> after the last </Sentence>. In the text, every </Sentence> is followed by 3 spaces. I tried capturing the last </Sentence> using...

preg_match_all question

Hey guys, For the last couple of hours i've been messing around with regex. I've never dared to lay my hands on this so please bare with me. Basicly i'm trying to get some info from the following source <random htmlcode here> <td style="BORDER-RIGHT-STYLE:none;"> <a id="dgWachtlijstFGI_ctl03_hlVolnaam" title="Klant wijzigen" cl...

REGEXP in MySQL Return unwanted value

Hi all I have problem using REGEX in Mysql I have oid value in database like this id -> value 1.3.6.1.4.1 -> Value a 1.3.6.1.4.1.2499.1.1.2.1.1.1.1.1 -> Value b 1.3.6.1.4.1.2499 -> Value c And my objecttives are 1. To get single oid & value with the specific oid that i put into sql statement 2. If no specific value the...

Flex Regular Expression Help

Hello guys. Im using regular expression to search word in a string for Example here var patrn:RegExp = new RegExp("\\bit's\\b"); var str:String = "Heres my problem in it and it's so help me guys."; trace(patrn.exec(str));//result is null My problem is I can't search the data in a string which has special character like ('/,/.). What...

Tagging phrases in paragragh

I am using PHP and I am looking to create links within my text to other sections of the site so for example: I fell into the media industry aged 30, when David Mansfield, now on the board of Ingenious Media, gave me my first break at Thames TV. From there, I worked at the (now-defunct) Sunday Correspondent and IPC, before joining TDI, w...

How can I match '&amp;' with JS RegExp

Hi! I have an url-encoded url (so with & replaced to &amp;), but I want to replace all the occurences of &amp; back to & using javascript. Currently I'm using myStr.replace("/&amp;/g", "&"), but that doesn't work (replaces nothing). Thanks, Lex ...

regex in groovy

I need to remove "" from the both ends of the line "/home/srinath/junk/backup" and to display like this /home/srinath/junk/backup How can we achieve this in groovy ? thanks in advance, sri.. ...

How to match a block of <li></li> using regexp

Hi guys, how can I match a block of <li>item 1</li> <li>item 2</li> no matter there is a blank line before or after the block and enclose it in <ul></ul> tags using PHP's preg_* functions. Thank you for answer ...

Validating DNS with Regex...

I need to validate a string that should contain DNS. Which regex is appropiate? ...

reg. exp. find tag with attribute

hi there, i need a reg exp (to do a preg_replace) to find all <font> tags with a style="..." attribute... the problem is that i need to match ONLY the <font> with a style attribute AND a value of "height: 0;overflow: hidden;width: 0; position: absolute;"... another problem, the style attribute may be in different positions; ex. <...

regular expression pattern

I want to match this : eight(8) alphanumeric characters followed by - hyphen followed by twentytwo(22) alphanumeric characters, here is what I tried and its not matching : [8]\w+-[22]\w+ ...

How to Remove HTML markup except for text completely outside every tag?

Hello, I am in a situation where I am having HTML markup with some text outside of it (leading or trailing). What regex should I be using? For example: some text over here <Html> <Title>website</Title> <Body> text text text <Div>xxxxx</Div> </Body> </Html> ending text So, I should be getting "some text over here" and "ending text" onl...

auto-generated examples for regexp?

Possible Duplicates: Reverse regular expressions to generate data Random string that matches a regexp hello, i wonder if it's possible to auto-generate valid data by specifying a regular expression. what i want to do is: providing a regular expression and auto-generate examples of data where the regular expression matches f...

Getting values from XML in Android (API Level 3)

I have a string that contains a xml structure and there are two pieces of data in separate tags that I am after. xpath has been added since API level 8, and with me being stuck with API level 3 (old phone for you ;-)) I need a way to get the data. Would using a regular expression commit a huge sin? ;-) The xml isn't that big... Looki...

Regex to match tags like <A>, <BB>, <CCC> but not <ABC>

hi all, i need a regex to match tags that looks like <A>, <BB>, <CCC>, but not <ABC>, <aaa>, <>. so the tag must consist of the same uppercase letter, repeated. i've tried <[A-Z]+>, but that doesn't work. of course i can write something like <(A+|B+|C+|...)> and so on, but i wonder if there's a more elegant solution. thanks. ...

Flickr photo URL replacement regular expression

Hi, I'm trying to write a regular expression to modify URLs stored in a database (linking to photos on Flickr) so I can change the size of photos already on a site - E.g. Replace: 4724575242_ca7d120609.jpg with 4724575242_ca7d120609_z.jpg in a URL such as: http://farm2.static.flickr.com/1045/4724575242_ca7d120609.jpg The only change ...

C#: Regex: Determining which pattern matched using Regex.Matches.

I'm writing a translator, not as any serious project, just for fun and to become a bit more familiar with regular expressions. From the code below I think you can work out where I'm going with this (cheezburger anyone?). I'm using a dictionary which uses a list of regular expressions as the keys and the dictionary value is a List<string...

White Space in Key of Associative Array PHP

I'm parsing out an HTML table and building an array based on the row values. My problem is the associative keys that are returned have a bit of white space at the end of them giving me results like this: Array ( [Count ] => 6 [Class ] => 30c [Description] => Conformation Model (Combined 30,57) ) So a line like this: echo $myAr...

PHP PCRE replace markup style

Hi, I need a PCRE expresssion (regex) to match and replace a certain attribute and value related to a markup element, something like this : <div style="width:200px;"></div> into <div style="width:100px;"></div> What I have now, parsed by simplehtmldom is the style content in plain text, like this : width:200px; How can I match ...

Regex for String Parameter!

I am trying to implement a Url Rewriting and struggling to figure out pattern matching for SC%3aArgument1+Argument2+%26+Argument3+Argument4. Any help is great!! ...