regex

Can I use Character Encoding for Regular Expressions?

Can I use Character Encoding for Regular Expressions...? e.g. this.html().replace(/&lt;\/?[^&gt;]+>/gi, '') Instead of: this.html().replace(/<\/?[^>]+>/gi, '') ...

Regular Expression to capture the first <p> of HTML

I have the following regular expression: (?:<(?<tag>\w*)>(?<text>.*)</\k<tag>>) I want it t grab the text within the first HTML element. eg. <p>This should capture</p>This shouldn't Works, but ... <p>This should capture</p><p>This shouldn't</p> Doesn't work. As you'd expect, it returns: This should capture</p><p>This shouldn't...

Multiple delimiters using Regex.Split in C#

Let's say you need to split a string by various delimiters including newline (/r, /n) and a few other 'special' character strings. For example: This is a sample %%% text &&& that I would like to split %%% into an array. I would like the following in the resulting string array (contents via index) [0]This is a sample [1]text [2]th...

Regex - how to tell something NOT to match?

How can I create a regex NOT to match something? For example I want to regex to match everything that is NOT the string "www.petroules.com". I tried [^www\.petroules\.com] but that didn't seem to work. ...

Mutually exclusive regular expressions

If I have a list of regular expressions, is there an easy way to determine that no two of them will both return a match for the same string? That is, the list is valid if and only if for all strings a maximum of one item in the list will match the entire string. It seems like this will be very hard (maybe impossible?) to prove definiti...

How to write a regular expression for "everything between X and Y" for use with preg_replace

I want to take a variable called $encoded_str and and remove cd1, CD1 and anything between the first 'l' and the last blank space. So for example "lp6 id4 STRINGcd1" would return "STRING". I'm using PHP 4 for now so I can't use str_ireplace, I have this: $encoded_str=str_replace('CD1','',$encoded_str); $encoded_str=str_replace('cd1',''...

Regex statements for date ranges <=4/1/2009 and <=10/01/2009

Hi, I need serious help building two Regex statements for a project. The software we're using ONLY accepts Regex for validation. I need one that fires for any date <4/1/2009 and a second that fires for any date <10/1/2009 My co-worker gave me the following code to check for <=10/01/2010, but it checks leap years and all that stuff. ...

is there a free open source text area type component for java which supports any number of regular expressions which will be highlighted in the text

I am looking for an existing free component that can support any number of regular expressions that will be highlighted in the text in any colour. The regular expressions should be configurable to work on a line by line basis, or spanning multiple lines. If such a component does not exist, i am considering creating it. In the past whe...

php regex guitar tab (tabs or tablature, a type of music notation)

I am in the process of creating a guitar tab to rtttl (Ring Tone Text Transfer Language) converter in PHP. In order to prepare a guitar tab for rtttl conversion I first strip out all comments (comments noted by #- and ended with -#), I then have a few lines that set tempo, note the tunning and define multiple instruments (Tempo 120\nDefi...

Match "81" in "630.81.11" using regex

I want to match "81" in "630.81.11". I'm stuck with \.[0-9]*\. which includes the dots. ...

Javascript Regex Camel Case - Sentence Case

How can I convert a string into camel case using javascript regex? "EquipmentClass name" or "Equipment className" or "equipment class name" or "Equipment Class Name" should all become: "equipmentClassName". Thanks. ...

How to Redirect Subdomains to Other Domain

What I'm trying to accomplish with htaccess mod-rewrite: Redirect all sub-domains to new domain name w rewrite rule. e.g. test1.olddomain.com ===> test1.newdomain.com test2.olddomain.com ===> test2.newdomain.com test3.olddomain.com ===> test3.newdomain.com This is what I have so far which of course is wrong: Options +Foll...

Is there something like PHP's preg_replace_callback() in javascript?

What I want to do is str.replace(pattern, callback), not simply str.replace(pattern, replace_pattern), is it possible to do it in javascript? ...

Powershell Regex help in extracting text between strings

i Have an arguments like the one below which i pass to powershell script -arg1 -abc -def -arg2 -ghi -jkl -arg3 -123 -234 Now i need to extract three strings without any whitespace string 1: "-abc -def" string 2: "-ghi -jkl" string 3: "-123 -234" i figured this expression could do it. But this doesnt seem to work. $args -match '...

Optimizing a lot of Scanner.findWithinHorizon(pattern, 0) calls

I'm building a process which extracts data from 6 csv-style files and two poorly laid out .txt reports and builds output CSVs, and I'm fully aware that there's going to be some overhead searching through all that whitespace thousands of times, but I never anticipated converting about 50,000 records would take 12 hours. Excerpt of my ma...

Need help with a RewriteRule - Apache

Here's what I want to do: http://www.mysite.com/ > http://www.mysite.com/index.php http://www.mysite.com/asd > http://www.mysite.com/index.php?page=$1 asd will be the name of the page(s) that get appended to index.php's $page variable. My current rewrite rule successfully redirects the requested page but fails to load th...

Extract from string in Java

I have a string; String value = "(5+5) + ((5+8 + (85*4))+524)"; How can I split/extract logical values from this string inside parenthesis as; (85*4) as one (5+8 + one) as two (two+524) as three ((5+5) + three) as four ... Any idea? all is welcome ...

Underscore not accepting in xml schema for email address

Hi I have created a schema and the following pattern to check for email id: \w+([-+._]\w+)*@\w+([-.]\w+)*\.\w+([-.]\w+)*. However it is not accepting email id's containing underscore like [email protected]. Can you please modify this pattern so that it accepts _ too. Thanks ...

Regexp: how to match everythings that is not into a pattern?

I want to match everything in a string that does not match a given pattern; for example [a-z]. Given the string abc4jkf8 4à3in, I need to match 48 4à3. I've tried with ([a-z])+(?![a-z]) but this matches exactly the opposite of what I need. With the string above, this regexp matches abcjkfin. Any ideas? ...

Regex lookahead, lookbehind and atomic groups

Ive found these things in my regex buddy but i dont got a clue what for i can use them ? does somebody got some examples so i can try to understand how they work? (?!) - negative lookahead (?=) - positive lookahead (?<=) - positive lookbehind (?<!) - negative lookbehind (?>) - atomic group ...