regex

What is the Java 1.4.2 equivalent of Pattern.quote()

What would be a Java 1.4.2 equivalent of Pattern.quote? I was using Pattern.quote() on a URI but now need to make it 1.4.2 compatible. ...

Splitting Nucleotide Sequences in JS with Regexp

I'm trying to split up a nucleotide sequence into amino acid strings using a regular expression. I have to start a new string at each occurrence of the string "ATG", but I don't want to actually stop the first match at the "ATG". Valid input is any ordering of a string of As, Cs, Gs, and Ts. For example, given the input string: ATGAAC...

What would this regex match?

Hi any idea what this is matching thanks preg_match('/^[1-8](0|5)$/', $myValue) ...

Is there a Windows utility that will let me do multiple programmatic find/replaces on text that I cut & paste into it?

I've inherited some C# code that contains about a thousand lines of source that I need to modify, transforming it from this: newDataRow["to_dir"] = comboBox108.Text; To this: assetAttributes.Add("to_dir", comboBox108.Text); The lines occur in various places throughout the application in groups of 40 or 50. Modifying each line by ha...

simple javascript regex question

How can I match the following pattern? "anything123.anythingelse" Alphanum of any length, with exactly 1 "." in the middle, and then alphanum of any length? Thanks. ...

Using Powershell regex to find PHP strings like "<?php eval "

Hello, I've been trying to find a string in PHP that matches something like this: Currently I've tried something like this; <()\?php eval(^>> but it dosen't seem to get the string correctly. edit: I forgot to add that I need to grab all the text form "" and it spans multiple lines. ...

JavaScript Regex: Complicated input validation

I'm trying to construct a regex to screen valid part and/or serial numbers in combination, with ranges. A valid part number is a two alpha, three digit pattern or /[A-z]{2}\d{3}/ i.e. aa123 or ZZ443 etc... A valid serial number is a five digit pattern, or /\d{5}/ 13245 or 31234 and so on. That part isn't the problem. I want c...

Regex: Strip non alpha numeric or punctuation.

How can I use PHP to strip out all characters that are NOT alpha, numeric, space, or puncutation? I've tried the following, but it strip punctuation. preg_replace("/[^a-zA-Z0-9\s]/", "", $str); ...

Scala capture group using regex

Let's say I have this code: val string = "one493two483three" val pattern = """two(\d+)three""".r pattern.findAllIn(string).foreach(println) I expected findAllIn to only return 483, but instead, it returned two483three. I know I could use unapply to extract only that part, but I'd have to have a pattern for the entire string, something...

regular expression for replace

I have a text like; <s:Label x="708" y="66" text="Label"/> <s:Button x="779" y="113" label="Button"/> and I need to replace the text="Label" to: text="{resourceManager.getString('trad', 'Label')}" What would be the easiest expression to do this? ...

get all values except { } in regex

Get all values from a string except the brackets { } So the string; now table { five } should be now table five I need it to be as regex ...

Regex to validate initials

I'm looking for a regex to validate initials. The only format I want it to allow is: (a capital followed by a period), and that one or more times Valid examples: A. A.B. A.B.C. Invalid examples: a. a A A B A B C AB ABC Using The Regulator and some websites I have found the following regex, but it only allows exactly one upper (...

Classic ASP comparison of comma separated lists

Hello, I have two comma separated lists:- 36,189,47,183,65,50 65,50,189,47 The question is how to compare the two in classic ASP in order to identify and return any values that exist in list 1 but that don't exist in list 2 bearing in mind that associative arrays aren't available. E.g., in the above example I would need the return...

regex to match charset

Hi, I've been trying to make a regex to match the charset of mime multipart emails so as I can decode them correctly. However I've found that there are some differences in the format that I can't seem to work out a regex for, as I'm no expert. currently I'm using (?<=charset=).*(?=;) however the examples I've found by sending emails fr...

preg_replace ('/σ/', 'ς', $cat_name);

Hi, how can change only the last letter of any word of a string with regular expressions? I use mb_strtolower() for change strings from upper to lower in Greek language and I have problem with final 's'. ...

Perl regular expression question

Suppose I have variables $x1 = 'XX a b XX c d XX'; $x2 = 'XX a b XX c d XX e f XX'; I want a regular expression that will find each instance of letters between XX. I'm looking for a general solution, because I don't know how many XX's there are. I tried using /XX(.*?)XX/g but this only matches "a b" for x1 and "a b", "e f" for x2 bec...

(PHP5) Extracting a title tag and RSS feed address from HTML using PHP DOM or Regex

Hi there, I'd like to get the title tag and RSS feed address (if there is one) from a given URL, but the method(s) I've used so far just aren't working at all. I've managed to get the title tag by using preg_match and a regular expression, but I can't seem to get anywhere with getting the RSS feed address. ($webContent holds the HTML o...

Get URL parameter function that gets value of url part or returns true if it's there but with no value?

I'm using the following function to get a URL parameter. function gup(name, url) { name = name.replace(/[\[]/, '\\\[').replace(/[\]]/, '\\\]'); var results = new RegExp('[\\?&]'+name+'=?([^&#]*)').exec(url || window.location.href); return results == null ? null : results[1]; } It works only if the parameter has a value, for exam...

JS regex isn't matching, even thought it works with a regex tester

I'm writing a piece of client-side javascript code that takes a function and finds the derivative of it, however, the regex that's supposed to match with the power rule fails to work in the context of the javascript program, even though it sucessfully matches when it's used with an independent regex tester. The code is extremely bare-bo...

what is the regular expression for this

I want to parse this (adv) much (thanks) I want to eliminate the words and the bracket (adv) but not (thanks) the condition is: inside bracket, and word length inside bracket is 1-5 characters I am using preg_match in PHP Thank You ...