regex

Find ASCII "arrows" in text

I'm trying to find all the occurrences of "Arrows" in text, so in "<----=====><==->>" the arrows are: "<----", "=====>", "<==", "->", ">" This works: String[] patterns = {"<=*", "<-*", "=*>", "-*>"}; for (String p : patterns) { Matcher A = Pattern.compile(p).matcher(s); while (A.find()) { System.out.prin...

Regular Expression To Extract Lines Not Cotaining HTML Block Tags

Hi. I'm looking for a regular expression to extract all adjacent lines not containing HTML block tags, but they can contain HTML inline tags. For example, if I have the following text ... bla bla bla bla bla <code>bla bla</code> bla bla bla bla bla <img src="" alt="" /> bla bla bla bla <div> bla bla bla bla bla bla ... I would like t...

Windows advanced file matching

I'm trying to use a batch file to list files in a directory such that the file name only (minus extension) matches only numeric patterns, e.g. something like 125646543.pdf which would be easy to express as a regex [\d]+\.pdf but of course I don't have such niceties with Windows-only mechanisms... I'm trying to do this with Windows-only m...

Read MIME data using PHP

Hello, I have a third party program which basically allows users to send email and then it displays it in the system. But the problem is that it is generating an output like this: I want to just take this data and format it to something presentable. I would like to avoid REGEX. Are there any options or standard ways of displaying the co...

PHP regex using preg_match and capture group

I have a string that I want to search through: "Query Result: Val for ?f : http://www.rk.com/#steak Val for ?a : http://www.rk.com/#movietheaters" The two variables that I want to capture are the two words after the hashes (in this case steak and movietheaters). Note that there will always be an uri infront of the #. I know I can easi...

Regex using javascript to return just numbers.

Hi, If I have a string "something12" or "something102". How would I use regex in javascript to return just the numbers parts?? Malcolm ...

regex read string matcher.matches first string not match properly

Someone help me i have a file containing following a // true тодорхойгүй гишүүн\n // false ямар нэг // false нэгэн // false a good deal // true нэлээн // false a long face // true уруу царай // false ... My java code while...

How do I detect groups of common strings in filenames

I am have been trying to figure out a way I can detect series of files. For instance: If a given directory has the following files: Birthday001.jpg Birthday002.jpg Birthday003.jpg Picknic1.jpg Picknic2.jpg Afternoon.jpg. I would like to get the condense the listing to something like Birthday ( 3 pictures ) Picknic ( 2 pictures ) ...

Help with regexp to extract values from inside brackets

I would like to get a regexp that will extract out the following. I have a regexp to validate it (I pieced it together, so it may not be the the best or most efficient). some.text_here:[12,34],[56,78] The portion before the colon can include a period or underline. The bracketed numbers after the colon are coordinates [x1,y1],[x2,y2].....

Regex Allowing for Hours in 15 Minute Increments

I need a regex which restricts an hour entry from 0-24 with the fraction in multiples of .25. Please keep in mind the following conditions must be met: When whole part is 0-23, the fractional part can be .0, .25, .5, or .75 When whole part is 24, the fractional part can be .0 When no whole part is present, the fractional part must be ...

How to get subset of string using Javascript/JQuery/JSON?

Hi, I want to get a subset of a string in Javascript. Currently, I only know how to store the entire string: I have this as a JSON variable with a callback to foo: foo({"results":[ "<div id=\"following\"><span><a href=\"http://twitter.com/barackobama\"&gt;Obama&lt;/a&gt;&lt;/span&gt;&lt;/div&gt;" ]}) And this is my callback function:...

JavaScript Regex Ignore Case

Hi, I am trying to match a part of the string and it should be NOT case sensitive. I have the following code but I never get the replaced string. var name = 'Mohammad Azam' var result = name.replace('/' + searchText + '/gi', "<b>" + searchText + "</b>"); The searchText variable will be "moha" or "mo" or "moh". How can I get the m...

How do I match a whole sentence in Javascript Regular Expressions?

I need to create a Regular Expression (in Javascript) that will match a specific sentence structure. In my case, it's "Course ### day ###", where ### can be any 1 to 3 digit number. Additionally, it can be "week" instead of "day", so "Course ### week ###" is also valid. So far, I've come up with: var regTest=/^(Course) \d{1,3} (day)|...

Regular expressions in cucumber steps

Cucumber generates out some neat webrat regex steps. I encountered a problem when I tried the this. In feature: And I fill in "Telephone (Home)" with "61234567" In webrat steps: When /^I fill in "([^\"]*)" with "([^\"]*)"$/ do |field, value| fill_in(field, :with => value) end The error encountered: Could not find field: "Telep...

Why am I getting empty results in my RegExp?

I am trying to parse my URL into different parts using this RegExp: ([\w\\.-]*) Given an example URL http://www.foo.com/bar/baz I get those results from preg_match_all(): Array ( [0] => Array ( [0] => http [1] => [2] => [3] => [4] => www.foo.com [5] => [6] => bar ...

Regex-based UPDATE for MS SQL Server 2005

I need to do this for a whole DB column foo: Regex regex = new Regex(@"^([A-Z][A-Z])(\d{6})$"); foo = regex.Replace(foo, "${1}0${2}")); What is the simplest way to do this? I'm completely alien to MS SQL Server programming, and to C#, actually. Can I get the job done without preliminary 200 hours of CLR/MS SQL Server/T-SQL training? ...

Regular expression library that returns all matches for multiple patterns in one run for C++?

I'm looking for a regular expression (or something else) library for C++ that would allow me to specify a number of patterns, run on a string and return the matching locations of all patterns. For example: Patterns {"abcd", "abcd"} String {"abcd abce abcd"} Result: abcd matches: 0-3, 11-14 abce matches: 5-9 Anyone know of a such a lib...

How do you match one of two words in a regular expression?

I want to match either @ or 'at' in a regex. Can someone help? I tried using the ? operator, giving me /@?(at)?/ but that didn't work ...

Regex to extract subdomain from URL?

I have a bunch of domain names comining in like this: http://subdomain.example.com (example.com is always example.com, but the subdomain differs). I need "subdomain". Could someone with regex-fu help me out? ...

C#, regular expressions : how to parse comma-separated values, where some values might be quoted strings themselves containing commas

In C#, using the Regex class, how does one parse comma-separated values, where some values might be quoted strings themselves containing commas? using System ; using System.Text.RegularExpressions ; class Example { public static void Main ( ) { string myString = "cat,dog,\"0 = OFF, 1 = ON\",lion,tiger,'R = red, G ...