regex

How to get files from 1 to n in a particular pattern?

Suppose you have files like: NewFile.part01.zip NewFile.part02.zip NewFile.part04.zip NewFile.part06.zip NewFile.part07.zip How do you get the files in this patter so you only get a SINGLE file called "NewFile" and also get the missing ones as integers, in this case (3, 5) Right now I am checking files one by one and if the name only...

jquery , append html

Hi! I have this kind of HTML : <h1> Text1 Text2 </h1> I want via jquery to change this HTML in : <h1> <span>Text1</span> Text2 </h1> I my head is coming just append and regular expression (maybe you have another ideas ) , unfortunately I don't have experience with "regex" . The "Text1" is changeable .. It should be the first te...

Splitting unicode (I think) using .split in ruby

Hi all- I am currently scraping an rss feed from last.fm and the title attribute looks like it has a unicode "-" that comes up as \u2013 on firebug. Here is the feed for those that are curious: http://ws.audioscrobbler.com/2.0/user/rj/recenttracks.rss When I write something like this feedentry.title.split('-') it won't find the un...

How can tokenize this string in java?

How can I split these simple mathematical expressions into seperate strings? I know that I basically want to use the regular expression: "[0-9]+|[*+-^()]" but it appears String.split() won't work because it consumes the delimiter tokens as well. I want it to split all integers: 0-9, and all operators *+-^(). So, 578+223-5^2 Will be s...

How to perform link rewriting with a .NET Regex?

I need to use C# Regex to do a link rewrite for html pages and I need to replace the links enclosed with quotes (") with my own ones. Say for example, I need to replace the following "slashdot.org/index.rss" into "MY_OWN_LINK" However, the actual link can be of the form "//slashdot.org/index.rss" or "/slashdot.org/index.rss" whe...

regular expression for line length and multiline input

Hi I have tried to create a regular expression that would match if the input text has max 3 lines of text, at most 10 characters per line, and characters are all uppercase. So this string should match: "AA\n\nAA" but this shouldn't "A12c" I thought this would work: (I enabled multiline in Pattern) (^[A-Z]{0,10}$){0,3} but it doesn'...

How to find a Word that is enclosed from Html Tags?

I'm programming a spell checker in Javascript in combination with OpenOffice dictionary, and I have a serious problem. I can find whole words using RegEx, but if the word looks like prog<b>ram</b>ing, I can find it if I remove all html tags with the .text() method from jQuery. But how can I replace this word and rebuild the original htm...

Django Regex 'Break Out'?

How do you 'break out' of a regex in Django? Therefore if one of your URL tokens (after and before a slash /token/) needs 3 digits, a COLON, 3 letters, a 'T' and then 2 digits, a DASH and then 3 digits - how would you do this? Example: Accept: 678:bhgT23-789 Reject: 345:fdsM43-432 I've started off with a r'^(?P<somevar>\w{2})/', but...

Regex: Selecting Text within Templated Syntax

Quick Question for anyone who is good at Regexes. I am trying to obtain the 'value' part of this syntax: [name:value] I got as far as: \[name:(\w*)] Which matches the entire thing. Does anyone know the changes I would need to make to select only value? (Bearing in mind that syntax will also be surrounded by other text. Thanks Dam...

PHP regular expression needed to replace line breaks, but only those between quotes

Hey everyone, our customer supplied us with XML data that needs to be processed using PHP. They chose to abuse attributes by using them for big chunks of text (containing line breaks). The XML parser replaces the line breaks with spaces to make the XML W3 compliant. To make sure we do not lose our line breaks, I want to read in the fi...

Simple Regex Help

Hi All, How do I grab the email inside a string using Regex? My string is as follows "First Last <[email protected]>" I want to grab "[email protected]" and store it somewhere. Thanks in advance! ...

regular expression

Hi i have a string like this: adfsdf dsf {{sadfsdfadf {{Infobox}} musical}} jljlk }} i want eliminate all substring {{..}} and so i tried with \{\{.*\}\} this eliminates {{sadfsdfadf{{Infobox}} musical}} jljlk }} but i want eliminate {{sadfsdfadf {{Infobox}} musical}} checking the }} more near from the start of the substring How ...

Split a string on commas not contained within double-quotes with a twist

I asked this question earlier and it was closed because it was a duplicate, which I accept and actually found the answer in the question Java: splitting a comma-separated string but ignoring commas in quotes, so thanks to whoever posted it. But I've since run into another issue. Apparently what I need to do is use "," as my delimiter wh...

regex for state abbreviations (python)

I am trying to create a regex that matches a US state abbreviations in a string using python. The abbreviation can be in the format: CA Ca The string could be: Boulder, CO 80303 Boulder, Co Boulder CO ... Here is what I have, which obviously doesn't work that well. I'm not very good with regular expressions and google didn't tur...

Xcode lazy regular expression

I'm trying to replace something like this: NSSomeFunction(@"some var", @"another one") With: NSSomeOhterFunction(@"some var") In Xcode. So these are source files... I bet the regular expression will look something like this: NSSomeFunction\((.*), .+\) But I need this to be lazy. Otherwise .+) will match the last parenthesis occu...

Why is s/^\s+|\s+$//g; so much slower than two separate substitutions?

The Perl FAQ entry How do I strip blank space from the beginning/end of a string? states that using s/^\s+|\s+$//g; is slower than doing it in two steps: s/^\s+//; s/\s+$//; Why is this combined statement noticeably slower than the separate ones (for any input string)? ...

How to make correct regular expression

I want to get ${1} = Title, ${2} = Open, ${3} = Bla-bla-bla. from {{Title|Open Bla-bla-bla }} ...

Why is my regex is not matching?

I have some lines in a text file like this: ==Text== I'm trying to match the start, using this: line.matches("^==[^=]") However, this returns false for every line... little help? ...

How can I write only certain lines of a file in Perl?

I am looking for a way to read an input file and print only select lines to an output file in Perl. The lines I want to print to the output file all begin with xxxx.xxxx.xxxx, where x is an alphanumeric character (the periods are periods, not wildcards). The lines do not all have the same ending, if that makes a difference. I'm thinking ...

Particular java regular expression

Hi, How would I check that a String input in Java has the format: xxxx-xxxx-xxxx-xxxx where x is a digit 0..9? Thanks! ...