regex

Regex how to match an optional character

I have a regex that I thought was working correctly until now. I need to match on an optional character. It may be there or it may not. Here are two strings. The top string is matched while the lower is not. The absence of a single letter in the lower string is what is making it fail. I'd like to get the single letter after the startin...

php Seperate quotes from string

Hello The following code keeps giving me this eroor "Parse error: syntax error, unexpected T_VARIABLE in ..." ? $query_string = 'this is a test... "this is in quotes" mmm..chicken burgers... yummm...'; preg_match_all("/\".*\"|[^\s]*/", ­ $query_string, $matches); echo "Matches:"; foreach($matches[0] as $token) { ...

Move title attribute value to class attribute value in the HTML code

We have variable $menu with HTML inside (there is no loop, it comes from a function). On echo it gives the code like this: <ul id="menu"> <li id="some-id" class="many classes"><a title="one" href="#">text</a></li> <li id="some-id" class="many classes"><a href="#">text</a></li> <li id="some-id" class="many classes"><a title=...

c# regex to extract link after =

Couldn't find better title but i need a Regex to extract link from sample below. snip... flashvars.image_url = 'http://domain.com/test.jpg' ..snip assuming regex is the best way. thanks ...

Verify an input file name on a form using regular expression

Hi, i need to verify that an input file in an html form is an image, i've made the follow code inside the html page, but don't work... script type="text/javascript" language="javascript" function valida(f){ var campo = f.immagine.value; //window.alert(campo); var er = /^+.[\.]([jpg]|[gif]|[png])$/; ...

Help with regular expression

I need a regular expression that, given an ingredient line, will tell me the quantity of that ingredient. Here are some sample values: 8 ounces semisweet chocolate 6 eggs 3/4 cup sugar 1-tablespoon espresso powder 1/2 cup Dutch processed baking cocoa 1/4 cup unsweetened cocoa 1/2 cup confectioners' sugar 2 cups heavy cream 2 to 4 dried...

Ruby regex: scan all

I have a string: TFS[MAD,GRO,BCN],ALC[GRO,PMI,ZAZ,MAD,BCN],BCN[ALC,...]... I want to convert it into a list: list = ( [0] => "TFS" [0] => "MAD" [1] => "GRO" [2] => "BCN" [1] => "ALC" [0] => "GRO" [1] => "PMI" [2] => "ZAZ" [3] => "MAD" [4] => "BCN" [2] => "BCN" [1] => "ALC" [2] => ... [3] => ......

Return a vbscript regex match on multilines

I am using vbscript regex to find self-defined tags within a file. "\[\$[\s,\S]*\$\]" Unfortunately, I am doing something wrong, so it will grab all of the text between two different tags. I know this is caused by not excluding "$]" between the pre and post tag, but I can't seem to find the right way to fix this. For example: [$Stri...

Get the HTML value which is not in a tag in c#

I have an HTML string that has the following form: <tr valign="top"><td colspan="2" style="padding-bottom:5px;text-align: left"><label for="base_1001013" style="margin-bottom: 3px; float: left">Nom d'utilisateur:&nbsp;</label><span style="float: right;"><input class="PersonalDetailsClass" type="text" name="base_1001013" id="base_1001...

Regex for Parsing Tweets for Links

I found a link in a tweet that my current regex won't parse and I can't seem to figure out how to get it working (probably due to my ineptness with regex). Here's the current code: preg_match_all('@((https?://)?([-\w]+\.[-\w\.]+)+\w(:\d+)?(/([-\w/_\.]*(\?\S+)?)?)*)@',$description, $matches, PREG_SET_ORDER); And the Tweet that won't p...

php regex problem

if(strlen(trim($steamid)) != 0) { $regex = "/^STEAM_0:(0|1):[0-9]{1}[0-9]{0,8}$/"; if(!ereg($regex, $ssteamid)){ echo "STEAM ID invalida"; } } Hi, my problem is that this isn't working as it should. STEAM ID's have maximum of 18 characters and ...

How to check and extract string via RegEx?

I am trying to check if a string ends in "@something" and extract "something" from it if it does. For example, I am trying to do something like this: string temp = "//something//img/@src" if (temp ends with @xxx) { string extracted = (get "src"); ... } else { ... } How can I accomplish this? ...

notepad++ regular expression delete line starting with \pard.....ending with line feed

I'm cleaning up files using notepad ++, and trying to delete lines that start with \pard and have some text then end with a line feed. But \n doesn't work in regular expression and .* doesn't work in an extended find and replace. This is what I've tried unsuccessfully. \pard.*\n \pard.* works but leaves the line feed in regex. Any ide...

This regex not working for <b>

</?(?i:script|div|table|frameset|b|frame|iframe|style)(.|\n)*?> I'm trying to filter certain HTML elements using this regex expression. I also want to filter "b" and "/b" as well but it doesn't seem to work for those. Thank you. ...

php preg_match to validate twitter handler

Hi, Please tell me the pattern to validate a twitter handler using preg_match Thanks ...

How to count string occurrence in string?

How can I count the number of times a particular string occurs in another string. For example, this is what I am trying to do in Javascript: var temp = "This is a string."; alert(temp.count("is")); //should output '2' ...

help with regular expressions

how can i match a text that is outside of an anchor tag ? example : "test <a>test</a>" i want to get the test outside of the a tags only. thanks. ...

Include the "minus-sign" into this regular expression, how?

I have this regex: var alphaExp = /^[a-zA-ZåäöÅÄÖ\s]+$/; This is for a name-field in a form validation. I need to make it possible to type names like this "Anna-nicole" (note the minus sign). Currently the minus sign causes error. I need to remake this regex so that a minus sign can be included in the name, preferrably make it so ...

string value greater than or equal to

I have a list of alpha-numeric values that I need to search through using a "greater than or equal to" and/or "less than or equal to" operator. Example list of values to be searched: a b c d e f User enters b, and specifies to return everything "greater than or equal to" it. Expected results: b c d e f What is the regular exp...

.gsub erroring with non-regular character 194

I've seen this posted a couple of times but none of the solutions seem to work for me so far... I'm trying to remove a spurious  character from a string... e.g. "myÂstring here Â$100" should be "my string here $100" I've tried string.gsub(/\194/,'') string.gsub(194.chr,'') string.delete 194.chr All of these still leave the  in...