regex

How can I match a tab to the end of the line with a Perl regex?

I have a file with the below contents: After learning everything you've learned so far, you may think you've bingo: got a pretty good foundation in programming Perl, since you'd already be a good way through most of the concepts many other languages entail. endbingo: But if you put down this book today and did nothing else bingo: ...

php preg_split error when switching from split to preg_split

Hi, I get this warning from php after the change from split to preg_split for php 5.3 compatibility : PHP Warning: preg_split(): Delimiter must not be alphanumeric or backslash the php code is : $statements = preg_split("\\s*;\\s*", $content); How can I fix the regex to not use anymore \ Thanks! ...

Parse address with regex

I have to create a loop, and with a regexp populate any of the 4 variables $address, $street, $town, $lot The loop will be fed a string that may have info in it like the lines below '123 any street, mytown' or 'Lot 4 another road, thattown' or 'Lot 2 96 other road, her town' or 'this ave, this town' or 'yourtown' since anything a...

Regex: Matching till first, not last occurency

Hi. I have a string like this: BEGIN blabla.. END; BEGIN one two END; And I want to make regex that will find this parts separately. I made regex (?i)BEGIN[\s\S]*(?i)END; But it finds this string as one instance matching. But I need two. How to make it search END; for first occurency, not last ? thanks! ...

How do i grab everything inside the BODY html tag (From a string) using RegEx Asp.net C#

{Yup, the above more or less explains it} :) Regex oRegex = new Regex("<body.*?>(.*?)</body>", RegexOptions.Multiline); The above doesnt seem to work if the body has any attributes in it. ...

Help Defining RegEx to Capture Line Definition from INI file

Need help defining an expression to capture the four numerics per line that define the lines on a map. 59.684 -4.251 59.575 -5.576 59.575 -5.576 59.437 -6.899 59.437 -6.899 59.27 -8.218 -7.346 23.196 -7.409 23.233 -7.409 23.233 -7.46 23.285 -7.46 23.285 -7.495 23.349 -7.495 23.349 -7.51 23.42 9.172 39.362 9.134 39 9.134 39.288 9.087 39....

Please help to understand this RegEx statement.

Please help to understand this RegEx statement in details. It's supposed to validate filename from ASP.Net FileUpload control to allow only jpeg and gif files. It was designed by somebody else and I do not completely understand it. It works fine in Internet Explorer 7.0 but not in Firefox 3.6. <asp:RegularExpressionValidator id="FileUpL...

How to uncheck Radio Buttons with regex?

How can i uncheck all radio button using jquery or javascript? The radio buttons i want to uncheck begins with the id=favoritepreferred12333 and the name favorite12333 the numbers 12333 can be different on other radio buttons, but they all begin with id=favoritepreferred{number} and the name=favorite{number} I think i have to use some r...

removing xml tag with regex

Hi, I need to remove the tag "image" with regex. I'm working with C# .Net example <rrr><image from="91524" to="92505" /></rrr> should become: <rrr></rrr> Anyone??? ...

Don't know whats wrong with this RegEx

Hi! I have to parse a string and capture some values: FREQ=WEEKLY;WKST=MO;BYDAY=2TU,2WE I want to caputre 2 groups: grp 1: 2, 2 grp 2: TU, WE The Numbers represents intervals. TU, WE represents weekdays. I need both. I'm using this code: private final static java.util.regex.Pattern regBYDAY = java.util.regex.Pattern.compile("...

How to solve this using regex?

Given that string: \n \n text1\n \ttext2\n Message: 1st message\n some more text\n \n \n Message: 2dn message\n\n \t\t Message: 3rd message\n text3\n I want to extract messages from a multiline string (token is 'Message: '). What regex expression should I use to capture those 3 groups: group 1 : '1st message' group 2 : '2dn mes...

How best use Regular Expressions to convert Heirarchical Text File into XML?

Good morning - I'm interested in seeing an efficient way of parsing the values of an heirarchical text file (i.e., one that has a Title => Multiple Headings => Multiple Subheadings => Multiple Keys => Multiple Values) into a simple XML document. For the sake of simplicity, the answer would be written using: Regex (preferrably in PHP)...

N-Insert In Sed

How would I replace the first 150 characters of every line with spaces using sed. I don't want to bring out the big guns (Python, Perl, etc) and it seems like sed is pretty powerful in itself (some people have written the dc calculator in it for example). A related problem is inserting 150 spaces in front of every line. s/^.\{50\}/?????...

Regex: Matching HTML elements that do not contain specific text

I need to strip out any movies that are not hosted by YouTube from html. Originally the request was to strip out any movies at all, for which <object.*object> worked pretty well. Now I basically need to do the same thing, but only if the stuff in the object tags is not hosted on youtube. I need a regex pattern that will match a strin...

Logical Parentheses for regex...?

So I am new to regex.... and what I can't make sense of is this... How can I search for a specific regex each time in a string, ie match all occurences of 'test' in a given string.... What could I use as a logical parantheses? /(test)*/ This returns several matches/Backreferences and doesn't seem to be meant for logically grouping/o...

Highlight Search Terms in PHP without breaking anchor tags using regex

I'm searching through some database search results on a website & trying to highlight the term in the returned results that matches the searched term. Below is what I have so far (in php): $highlight = trim($highlight); if(preg_match('|\b(' . $highlight . ')\b|i', $str_content)) { $str_content = preg_replace('|\b(' . $highlight. ')(...

Ruby doesn't recognize the g flag for regex...

Is it implied by default in str.scan? Is it off by default in str[regex] ? ...

mootools formcheck : regex for number validation

Hello, i need to validate currency field with formcheck plugin for mootools. It has number validation type, and number accepts regex to personalize validation. I need sample to validate: 1.000,01 --> ok 1,000.02 --> not ok 1000,12 --> ok 1000.13 --> not ok 10.000 --> ok 100.00 --> not ok and so on. Can you help me p...

How to detect a floating point number using a regular expression

What is a good regular expression for handling a floating point number (i.e. like Java's Float) The answer must match against the following targets: 1) 1. 2) .2 3) 3.14 4) 5e6 5) 5e-6 6) 5E+6 7) 7.e8 8) 9.0E-10 9) .11e12 In summary, it should ignore preceeding signs require the first character to the left of the decimal...

Select a HostName with Regex in C# ?

There are some addresses as follows : http://rs320tl.rapidshare.com/files/119371167/sth.rar I'm gonna select rs320tl.rapidshare.com with Regex, but I'm not familiar with Regular Expressions. Would you please guide me ? Thanks. PS. rs320tl in the address is variable. ...