regex

Need to match any string that contains [a-z0-9\x20] but with no spaces at the start or end and no double spaces

So far I have ^[a-z0-9]+[a-z0-9\x20]+[a-z0-9]+$ Which matches all criteria except not matching double spaces. ...

Matching everything except a specified regex

I have a huge file, and I want to blow away everything in the file except for what matches my regex. I know I can get matches and just extract those, but I want to keep my file and get rid of everything else. Here's my regex: "Id":\d+ How do I say "Match everything except "Id":\d+". Something along the lines of !("Id":\d+) (pseudo...

Matching mulitples

I need to match the following using preg_match() cats and dogs catsAndDogs i like cats and dogs etc, so i simply stripped out the spaces and lowercased it and used that as my pattern in preg_match(); '/catsanddogs/i' But now I need to match the following too: cats+and+dogs cats_and_dogs cats+and_Dogs So is there quick and easy w...

Regex filter for STL messages

Given the follow STL error: ./poly_power/poly_class.cpp:496: error: no matching function for call to ‘state_operator< polynomial< variable_term< polynomial< variable_term< std::basic_string<char, std::char_traits< char>, std::allocator< char> >, int> >, polynomial< variable_term<std::basic_string< char, std::char_traits< char>, std::all...

Exercises for Regular Expressions?

Apart from what is available in the books about Regular Expressions, are there any web sites / blogs series / etc. with a bunch of exercises that are somehow more "real world" that the ones in most of the books? My specific problem is that currently I don't have specific needs / areas where I can exercise what I've learned about RegEx, ...

Java regex to extract integer from large body of text.

I need to extract a value from a large body of text. I'm assuming the best way to do this would be to use a regular expression. If anyone thinks there's a better way to do it, feel free to offer up a suggestion. The value I need to extract always appears in a string of the form: [formatted_int_value] results across [the_integer_value_I...

Regular Expressions - Match records i HTML

I have to match a large amount of records in HTML. I want each record matched with a regular expression (using .NET Regex Match). Each record is formatted like this (the total HTML contains of normal HTML and ~100 records like the following): <tr onclick="window.location.href='Vareauktion.asp?VISSER=Ja&funk=detaljedata&ID=14457'" sty...

regex for telephone number

Possible Duplicate: A comprehensive regex for phone number validation Just a simple regex required to validate telephone numbers. Must contain only digits, and the other allowable characters are spaces and dashes. ...

reading a file using java scanner

One of the lines in a java file I'm trying to understand is as below. return new Scanner(file).useDelimiter("\\Z").next(); The file is expected to return upto "The end of the input but for the final terminator, if any" as per java.util.regex.Pattern documentation. But what happens is it returns only the first 1024 characters from the...

Ruby regular expressions - speed problem

I want to obtain the information of students in class c79363 ONLY. The following file(users.txt) contains the user id's c79363::7117:dputnam,gliao01,hmccon01,crober06,cpurce01,cdavid03,dlevin01,jsmith88 d79363::7117:dputn,gliao0,hmcc01,crob06,cpur01,cdad03,dlen01,jsmh88 f79363::7117:dpnam,gli01,hmcn01,ober06,crce01,cdav03,dln01,jith8...

getting aliases from config by regular expression (bad separated)

Hey guys, I tried to get some aliases from a specific config file in a short bash script. The config looks like: [other config] [alias] alias: command -o option alias2: command -l 2 alias3: command -o option [other config] How would you get these aliases separated? I would prefer a output like this: alias: command -o option alias...

Regular Expression for dd-MMM-yyyy and dd-MMM?

I need a regular expression for support both date formats dd-MMM-yyyy and dd-MMM. Ex: 04-Oct-2010 04-Oct 04-OCT-2010 04-OCT ...

Regular Expression to match everything that appears before a colon?

I need to remove some data from an RSS feed. It's everything that appears before a : and also preferably the space that appears just after the : Example: Hello : Charlie wants to know how to delete everything behind him from behind the colon and one space in front. I will always have this question mark on the end? Where the : and hel...

Parsing Numeric Values with Java's Regular Expression Classes

In Java, I'm attempting to parse data from an ASCII output file. A sample of the data looks is show below. The values are formatted precision 5 scale 3 and no space exists between the values. 80.234 <- 1 value 71.01663.129 <- 2 values ... 67.09159.25353.997 56.02759.77859.25057.749 55.86558.46958.64861.72855.969 What regular express...

need a regex for a positive max 2 digits after . floating number

Hi I need a C# regex for a positive floatin no with maximum 2 digits for decimals. Also the regex should check for letters and alphanumerical chars (not allow them) and not allow also the input value to be empty (0 characters). Thanks ...

Preg_Match_All: two values in a pattern

I have custom tags [tag val=100][/tag]. How do I get val and whatever goes between the tags? ex: [tag val=100]apple[/tag] value1 = 100 value2 = apple edit: what if I had multiple items inside the tag ex: [tag val=100 id=3] ...

Regular expression to replace period in name portion of e-mail header?

I am attempting to send an e-mail in PHP and the system is rejecting the e-mail because the name portion of the e-mail address contains a period like below: Mr. Joe Nobody <[email protected]> I am looking for an elegant solution to replace all periods that are not part of the e-mail address with either a space or no character at...

PHP Find String and Following Unknown Characters

Hi, I'm still learning PHP Regex so I'm hoping someone can help me with what I'm trying to accomplish. $string = 'Writing to tell you that var MyCode = "dentline"; Learn it.'; What I'd like to do is match the part of the string which reads var MyCode =" After I match that part, I want to retrieve the rest of the dynamically genera...

How do I replace all asterisks?

In Java, I want to replace all * characters with \*. Example: Text: select * from blah Result: select \\* from blah public static void main(String[] args) { String test = "select * from blah"; test = test.replaceAll("*", "\\*"); System.out.println(test); } This does not work, nor does adding a escape backslash. ...

vim regex replace multiple consecutive spaces with only one space

I often work with text files which have a variable amount of whitespaces as word separators (text processors like Word do this, to distribute fairly the whitespace amount due to different sizes of letters in certain fonts and they put this annoying variable amount of spaces even when saving as plain text). I would like to automate the p...