regex

String transforming with danger symbols

I have the followings string: String l = "1. [](a+b)\n2. (-(q)*<>(r))\n3. 00(d)\n4. (a+-b)"; String s = "1. [](a+b)\n2. 00(d)" First string is a expresions list. Sencond string is a expresions subset of first string, but theirs number-ids aren't equals. Then, I want to do this: String l2 = "1. <b>[](a+b)</b>\n2. (-(q)*<>(r))\n3. <b>...

Regex to check if a number is even

Can we have a regex to detect if a number is even ? I was wondering if we can have a regex to do this instead of usual % or bit operations. Thanks for replies :) ...

Parsing Custom JavaScript Annotations

Implementing a large JavaScript application with a lot of scripts, its become necessary to put together a build script. JavaScript labels being ubiquitous, I've decided to use them as annotations for a custom script collator. So far, I'm just employing the use statement, like this: use: com.example.Class; However, I want to support an...

java regex separate numbers from strings

Hello, I have got strings like: BLAH00001 DIK-11 DIK-2 MAN5 so all the strings are a kind of (sequence any characters)+(sequence of numbers) and i want something like this: 1 11 2 5 in order to get those integer values, i wanted to separate the char sequence and the number sequence an do something like Integer.parseInt(number_...

REGEX for only data and end tag

I am looking for REGEX which will give me data along with the end tag e.g. input: ----------------- <p>ABC<p> ----------------- Output would be ----------------- ABC<p> ----------------- it will only remove the first para para tag,Not for the second para tag and all text in between would be same. I want to mention here that i am ...

how to write regex starts and ends with particular string?

How to write regex for this paricular situation. Here letters in [] is not fixed but letters without [] is fixed. http://www.abc.com/fixed/[any small letters]/[anyletters]/fixed.html ...

How go get everything from between paranthesis in PHP ?

Array( [1] => put returns (between) paragraphs [2] => (for) linebreak (add) 2 spaces at end [3] => indent code by 4 (spaces!) [4] => to make links ) Want to get text inside brackets (for each value): take only first match remove this match from the value write all matches to new array After function arrays should look like: Array(...

Remove file extension and path from a string in perl

I want to obtain a file name without its path (if it is part of the string) and also the extension. For example: /path/to/file/fileName.txt # results in "fileName" fileName.txt # results in "fileName" /path/to/file/file.with.periods.txt # results in "file.with.periods" So basically, I want to remove anythin...

What is this regex doing?

/^([a-z]:)?\//i I don't quite understand what the ? in this regex if I had to explain it from what I understood: Match begin "Group1 is a to z and :" outside ? (which I don't get what its doing) \/ which makes it match / and option /i "case insensitive". I realize that this will return 0 or 1 not quiet sure why because of the ? Is t...

Regex to match from 0.0 to 150.0 (including floating point)

I have a problem: i should match values from 0.0 to a specific double value (for example, i should match from 0.0 to 150.00 including value as 12, 21.23213, 149.111) anyone can help me? i tried everything. i used this regexp for match by 0.0 to 60.0 but it doesn't work (^0(\.[0-9]+)?$|^[1-9]{1}(\.[0-9]+)?$|^[1-5]{1}[0-9]{1}(\.[0-9]+...

regex for finding Letter after Underscore

Hi I would like to write a regex using unix command that identifies all strings that do not confirm to the following format First Leter is UpperCase Followed by any number of letters Underscore Followed by UpperCase Letter Followed by any number of letters Underscore and so on ............. The number of underscores is variable ...

php: how to replace a letter NOT following a backslash

hi i want to replace all "e" in a string with "-" which are NOT following a backslash so "hello" should be -> "h-llo" but "h\ello" should be "hello" any ideas if this is possible with a single regex? ...

Regex Pattern to Extract Email Data

I'm retrieving raw text (includes header, and message) from a POP server. I need to capture everything after the header which is terminated by a blank line between it and the user message. At the same time I'm wanting to ignore anything from original messages if it's a reply. The start of a reply for the emails I'm parsing start with -...

Python Regular Expressions - Complete Match

Hello, for my CGI application I'm writing a function to get the browser's preferred language (supplied in the HTTP_ACCEPT_LANGUAGE variable). I want to find all language tags in this variable with regular expressions (The general pattern of a language tag is defined in RFC1766). EBNF from RFC1766 ('1*8ALPHA' means one to eight ASCII cha...

RegEx: Uk Landlines, Mobile phone numbers

I've been struggling with finding a suitable solution :- I need an regex expression that will match all UK phone numbers and mobile phones. So far this one appears to cover most of the UK numbers: ^0\d{2,4}[ -]{1}[\d]{3}[\d -]{1}[\d -]{1}[\d]{1,4}$ However mobile numbers do not work with this regex expression or phone-numbers writ...

Emacs align-regexp working with "="

Example code: f x | "s" == x = 1 | otherwise = 0 I can see the regexp as "match the equals sign when surrounded by whitespace characters". However, \s-+=\s-+ doesn't work (\s-+ is the pattern for 1+ whitespace) because it ends up inserting an extra space before the equals sign. I need a pattern that says "match empty string when t...

Validator throwing error.

I have the following RegularExpressionValidator on one of my pages: <asp:RegularExpressionValidator ID="RegularExpressionValidator2" runat="server" ControlToValidate="InKindTextBox" ErrorMessage="The value entered for 'Cash' must be in a number format. Ex...

check to see if a string contains an ip address

Hi, I have a file loaded into a stream reader. The file contains ip addresses scattered about. Before and after each IP addresses there is "\" if this helps. Also, the first "\" on each line ALWAYS comes before the ip address, there are no other "\" before this first one. I already know that I should use a while loop to cycle through e...

Is there a way to copy the case of a character and impose it on some other character in output?

VS2008 allows you to use regular expressions in the find/replace dialogs. I've run into a couple of moments where I've needed to copy the case of a specific character and impose it on the replace string. For example I have a block of code that has Monday and monday scattered throughout. I want to change each Monday to a Friday as well...

MySQL Reg ex, need to match phrases in any order

I am using a MySQL Database to search through a list of categories. My query is: select * from cat where name REGEXP('(region_Long Island)+(.)*(sport_Outdoor Track)'); where the values "region_Long Island" and "sport_Outdoor Track" are passed in. I need to be able to match these categories, regardless of the order they are in. In the t...