regex

preg_match: ensure the start and the end contains something

Hi, I want to have the regular expression that makes sure the beginning of the string contains 'http://' and '/' and the end. This is a longer version I came up with, if(!preg_match("/(^http:\/\//", $site_http)) { $error = true; echo '<error elementid="site_http" message="site_http - Your link appears to be invalid. Please confirm ...

Parse exported bookmarks file with ColdFusion

I need to parse a list of bookmarks exported from a browser like Chrome, Firefox and IE. Maybe even google etc. I played around and did something like this reMatchNoCase("(<h3)(.*?)(</dl>)",myfile1) loop. Then I use reMatchNoCase("(<dt[>])(.*?)(</a>)",i) within the h3/dl tags, and then a lot of cleanup, but its really not reliable. The...

extract url from xml response

I need to extract url from XML response. Here is the XML response: <cloud xmlns:xlink="http://www.w3.org/1999/xlink"&gt; <rootContainer xlink:href="https://api.example.net/v2/bucket/92FBC29C-344C-99CF-827E-1B5586A7F8E3" xlink:type="simple"/> </cloud> I'm using C to write regex. Need help. my output needs to be https://api...

How to find a URL within full text using regular expression

What is wrong with the following regular expression, which works in many online JavaScript regular expression testers (and RegEx Buddy), yet doesn't work in my application? It is intended to replace URLs with a Hyperlink. The Javascript is found in a javascript file. var fixed = text.replace(/\b(https?|ftp|file)://[-A-Z0-9+&@#/%?=~_|$...

Why is preg_replace giving this output?

I just can't figure this out, for some reason this: $string = "#mainparent { position: relative; top: 100px; left: 100px; width:4994px; }"; $elementwidth = "88"; $re1='(.*?)'; # Non-greedy match on filler $re2='(mainparent)'; # Word 1 $re3='(.*)'; # Non-greedy match on filler $re4='(width:)'; $re5='(.*)'; # Word 2 $re6=...

What is the problem with this regex?

First, I'm not a regex expert, so I'm pretty sure I'm doing something wrong. Here is my regular expression: <(list)(\b[^>]*)>(<\1\b[^>]*>.*?<\/\1>|.)*?<\/\1> This is the input string: ... <list title="Lorem ipsum dolor sit amet, consectetur adipiscing elit..."> <li> <list title="Lorem adipiscing..."> <li>Lorem ipsum dolo...

Embed code regular expression won't work

I have a regular expression that I have written in order to extract values that a user enters and replace some height and width values and keep the urls. This is so it can be safely added to a database. This is what I have so far (just trying to get the preg_match to return a TRUE value) $test ='<object height="81" width="100%"> <param...

How to add duplicate word using regular expression?

Instead of removing duplicate words using regular expression, how do I duplicate a word? My case: I have a list of emails that need to be turn to SQL queries. [email protected] [email protected] [email protected] To: mysql -e "select * from users where email='[email protected]" > /tmp/[email protected] mysql -e "select * from user...

What is the regular Expression to uncomment a block of Perl code in Eclipse?

I need a regular expression to uncomment a block of Perl code, commented with # in each line. As of now, my find expression in the Eclipse IDE is (^#(.*$\R)+) which matches the commented block, but if I give $2 as the replace expression, it only prints the last matched line. How do I remove the # while replacing? For example, I need to...

regex to identify inline style attributes in the HTML tag

From the html source file i've to identify tag with inline style attribute using java. For example <span id="abc" style="font-size:11.0pt;font-family:'arial black','sans-serif'; color:#5f497a"> Please help ...

Your typical sheep counting regular expression in python question

at night, after saying my prayers, i typically count sheep to help me fall asleep. i want a regular expression to help me with the correct count. i want the following strings to match 0 1sheep 2sheepsheep 3sheepsheepsheep and so on. what is the regular expression for this? something like '(\d+)(sheep){\1}' if {\1} would do what i wa...

" inside attribute in xslt

hi i am trying to write a regular expression inside an xslt but i have a problem with the " sign. i closes the attribute. and \" dosnt seem to work like it works in aspx pages here is my code: <xsl:if test="@text = 'yes'"> <asp:RegularExpressionValidator runat="server" ControlToValidate="{@name}" ValidationExpression="^[\w '%+*....

How to extract url GET parameter from <a> tag, from the full html text.

So I have an html page. It's full of various tags, most of them have sessionid GET parameter in their href attribute. Example: ... <a href="struct_view_distrib.asp?sessionid=11692390"> ... <a href="SHOW_PARENT.asp?sessionid=11692390"> ... <a href="nakl_view.asp?sessionid=11692390"> ... <a href="move_sum_to_7300001.asp?sessionid=1169239...

Should I use regex when trying to write a tokenizer?

I've written a small and simple tokenizer but without use of regular expressions. I starts at first index and iterates through every character until end and creates the required tokens. I showed it to a colleague that said it would've been much simpler to do /that/ with regex without going into any depths. So should I rewrite and e...

java regular expression matching

What is the regular expression that can match the following 2 strings. Hi<Dog>Hi and <Dog> in a given text. Update: What regex will match this one? If you access the web site click the link below: matches only till the first ...

Regular Expression for Alphabets + Numeric Value

Hello, I am working on a Java-script, for which I need regular expression to check whether the entered text in text-box should be combination of alphabets and numeric value. I tried NaN function of java-script but string should be of minimum-size & maximum-size of length 4 and start with Alphabet as first element and remaining 3 eleme...

PHP RegEx to get form values

If you're given a form in a string format like: <input type="hidden" id="thisID" value="Text Value" /> How can you get the value "Text Value"? Also with: <select name="thisSelect" size="1"> <option value="one">One</option> <option value="two" selected>Two</option <option value="three">Three</option> </select> How can you get ...

Selecting image url from html using javascript regexp

I'd like to select the image source url from html code using javascript regexp. I'm using it to simplify using picasaweb images in other websites. I'm rather new at this, and I constructed a regex using http://www.regular-expressions.info/javascriptexample.html, and there it works like a charm, but not in my own script. Can somebody poin...

How to match string with complex delimiters (regex in ruby)

Hello I would like to match attribute pairs from string similiar to the one below <tag_name attra="#{t("a.b.c")}" attrb="aa a"> ... sould match on attra="#{t("a.b.c")}" and attrb="aa a" thanks in advance Marius ...

What Regular Expression do I need to match "3213.32.2311" and similar?

I want a regular expression to match input like: 3213.32.2311 Format required is: Four numeric characters a . 2 numeric characters a . 4 numeric characters. ...