regex

Regular Expression Please

What would the regular expression be to find all instances of the following; file:///F|/rah/title.txt (47 of 199) [8/27/03 11:21:39 PM]</p><p class="Griegs3"> file:///F|/rah/title.txt Where the (47 of 199) changes to (48 of 199) etc. Bu I want to match from file:// in the first line to .txt in the second What I have been ased to do ...

Simple REGEX Question in PHP

I want to take data entered in this format: John Smith 123 Fake Street Fake City, 55555 http://website.com and store the values in variables like so: $name = 'John Smith'; $address = '123 Fake Street'; $city = 'Fake City'; $zip = '55555'; $website = 'http://website.com'; So first name will be whatever is entered on the first line a...

Swapping token values in a string through regex

Hi, I have tokenized names (strings), with the tokens separated by underscores, which will always contain a "side" token by the value of M, L, or R. The presence of that value is guaranteed to be unique (no repetitions or dangers that other tokens might get similar values). In example: foo_M_bar_type foo_R_bar_type foo_L_bar_type I'...

C# Convert Relative to Absolute Links in HTML String

I'm mirroring some internal websites for backup purposes. As of right now I basically use this c# code: System.Net.WebClient client = new System.Net.WebClient(); byte[] dl = client.DownloadData(url); This just basically downloads the html and into a byte array. This is what I want. The problem however is that the links within the h...

My PHP preg_match expression isn't working.

I tried to directly convert an "eregi" expression to a "preg_match" expression. $ACCEPT_CHARS = "a-z0-9_~#&;=./?+-"; $msg = preg_match("/ (http|https|ftp|gopher|news)://([$ACCEPT_CHARS]+)/i", "<a href=\"\\1://\\2\" target=\"_blank\">\\1://\\2</a>", $msg); However, I get: Warning: preg_match() [function.preg-match]: Unknown modifier '...

Simple regex extract folders

What would be the most efficient way to cover all cases for a retrieve of folder1/folder22 from: http://localhost:8080/folder1/folder22/file.jpg or http://domain.com/folder1/folder22/file.jpg or http://127.0.0.0.1:8080/folder1/folder22/file.jpg so there may be one or more folders/sub-folders. Basically I would like to strip the domai...

MySql Regular Expression Select Columns Matching (dynamic)multiple Values within Stored Procedure

I am trying to generate a query where I want to select columns(text) matching multiple values. eg: I have two columns, id and description. suppose my first row contains description column with value Google is website and an awesome search engine , second row with description column value Amazon website is an awesome eCommer...

Add quotes around each word

I want to transform in Java: dd fdas dd fdas fads f das fdasf + - || dasf into: "dd" "fdas" "dd" "fdas" "fads" "f" "das" "fdasf" + - || "dasf" basically I want to add quotes around words. \w* -> "\w*\" ...

How to find index of parenthesis indexOf - confusion, Eclipse bug or feature

I want to find position in( position within string, but I can not explicitly write: int index = valueOf("in("); because I get error of non closed group ( java.util.regex.PatternSyntaxException Unclosed group). If I escape parenthesis it will not find index of in(, but in\( int index = value.indexOf("in\\("); How can I achieve th...

asp.net mvc regular expression phone

[RegularExpression(@"^[a-zA-Z0-9_,:- ]*", ErrorMessage = "Phone can Contains only Only Alphanumeric Characters ")] How can I validate accomodate () ' in the above regular expression, it is giving a parsing error. ...

How can I use lookbehind in a C# Regex in order to skip matches of repeated prefix patterns?

How can I use lookbehind in a C# Regex in order to skip matches of repeated prefix patterns? Example - I'm trying to have the expression match all the b characters following any number of a characters: Regex expression = new Regex("(?<=a).*"); foreach (Match result in expression.Matches("aaabbbb")) MessageBox.Show(result.Value); r...

php regular expression for unicode

I have some text where unicode is written as text like this There areu25ba 2 boys. it should be like this There are&#x25ba 2 boys. Replace 'u' with '&#x' if there is unicode character. Thanks in advance ...

Returning a logical vector for matches: regexp supported?

I want to return a logical vector for regexp matches over a character vector, but match or %in do not seem to support regular expressions, e.g.: > x <- c("Bill", "Brett", "Jane") > grep("^B", x) [1] 1 2 > x %in% "^B" [1] FALSE FALSE FALSE I would like this to return [1] TRUE TRUE FALSE Ideas? Thanks, Roberto ...

Java: Pattern, Scanner example does not work

I am curious why this pattern doesn't work. String same = "==== Instructions ===="; Pattern title4 = Pattern.compile(same); Scanner scan = new Scanner(same); System.out.println(scan.hasNext(same)); returns: false ...

Java to Php conversion

I have a function in Java which I need to convert into php. It converts unicode text into characters. For example input is "Every person haveue280 sumue340 ambition"; I want to replace ue280, ue340 to \ue280, \ue340 with regular expression Here is code written in Java String in = "Every person haveue280 sumue340 ambition"; Pattern ...

Java: how to collect incoming data fragments into properly terminated strings for subsequent parsing?

I just joined StackOverflow after having found many great answers here in the past. Here's my first question: EDIT: I feel bad... my first question to StackOverflow turned out to be a "wild goose chase". The problem is in the data, not the code reading the data. I was looking for a solution in the wrong place! I will explain in a commen...

Regexp: remove first and last slash

Hi, I have these strings: /banking/bonifici/italia /banking/bonifici/italia/ and I would like to remove - with javascript - first slash and last slash if it's exists. I tried ^\/(.+)\/?$ but it doesn't work. Reading some post in stackoverflow I found that php has trim function and I could use his javascript translation (http://phpjs...

Remove "${anything}" from string in java

I want to remove ${anything} or ${somethingelse} from a string, but i dont find the regex. My actual code String url = http://test.com/index.jsp?profil=all&amp;value=${value} String regex = "\\$\\{*\\}"; url = url .replaceAll(regex, ""); // expect http://test.com/index.jsp?profil=all&amp;value= //but it is http://test.com/index.jsp...

RegEx Question - Remove everything between : and ~

I am having trouble getting a regex to work. This is the string. "some text would be here and Blah St:39.74908:-104.99482:272~Turn right over here" I need to remove the :39.74908:-104.99482:272~ part of the string. I am using jQuery if that helps. ...

Simple regular expression question (search in VS2008)

Hello, I am trying to change one of the legacy code that declares everything in arrays to a collection. I'd like to do a simple search-and-replace using regular expressions and I was wondering if anyone could help me out. For example, if arrays are declared this way: array[0] = "1"; array[1] = "2"; array[2] = "3"; array[3] = "4"...