regex

Whether to simplify two stage regular expression?

I'm newbie in Python, but this question is not a homework (actually this code helps to generate RSS on my Subversion server). I have an array of strings in the info_lines variable. And I want to replace each occurrence of the bug ID. My current code looks like the following: for ln in range(3, len(info_lines)): # skip two strings since...

Perl: Can I store backreferences (not their values) in variables?

I'd like to do something like this: my $text = "The owls are not what they seem."; my $pattern = '(\s+)'; my $replacement = '-$1-'; $text =~ s/$pattern/$replacement/g; $text should then be: The- -owls- -are- -not- -what- -they- -seem. But of course it's more like: The-$1-owls-$1-are-$1-not-$1-what-$1-they-$1-seem. I tried all ...

Regular expression where part of string must be number between 0-100

I need to validate serial numbers. For this we use regular expressions in C#, and a certain product, part of the serial number is the "seconds since midnight". There are 86400 seconds in a day, but how can I validate it as a 5-digit number in this string?: 654984051-86400-231324 I can't use this concept: [0-8][0-6][0-4][0-0][0-0] ...

Java : replacing text URL with clickable HTML link

Hello, I am trying to do some stuff with replacing String containing some URL to a browser compatible linked URL. My initial String looks like this : "hello, i'm some text with an url like http://www.the-url.com/ and I need to have an hypertext link !" What I want to get is a String looking like : "hello, i'm some text with an url ...

Regex to compare strings with Umlaut and non-Umlaut variations

Can anyone help me with a javascript regular expression that I can use to compare strings that are the same, taking into acccount their non-Umlaut-ed versions. for example, in German the word Grüße can also be written Gruesse. These two strings are to be considered identical. The mappings (ignoring casings for the moment) are: ä = ae ...

Can actual Perl Regular Expressions be implemented in Java via existing library?

Is there an existing robust Java library which implements a fairly substantial subset of Perl regular expression syntax? Background: I wish to implement a file renamer where renaming is done using Perl regular expressions. The trick is that the project containing said renamer as a component is, currently, 100% in Java in Windows. NOT...

What's a good regular expression to capture the root domain of a given url?

Ideally, I'd like to capture foo.com from something like http://foo.com/bar?param=value or https://www.foo.com Thanks. Edit: Sorry for the vagueness. I'll be doing this in Javascript. 2nd Edit: I should post my terrible first attempt: https?://w?w?w?[.]?[^?/] ...

Understanding Pattern and Matcher

Consider this code: import java.util.regex.*; public class Pattern3 { /** * @param args the command line arguments */ public static void main(String[] args) { // TODO code application logic here Pattern p = Pattern.compile("Our"); //line 1 Matcher m = p.matcher("Our mom and Our dad"); //line ...

Difference in regex email validation between jQuery plugin and org.springmodules.validation

Greetings! I have a Spring app and a form getting validated on the back and front ends. On the back end I'm using annotation based validation for the EMAIL field with help from org.springmodules.validation. So far so good. On the front end I decided to use the jQuery Form Validation plugin and discovered that front and back validation a...

Regex or XML Parser C#

Hello there, I have some word templates(dot/dotx) files that contain xml tags along with plain text. At run time, I need to replace the xml tags with their respective mail merge fields. So, need to parse the document for these xml tags and replace them with merge fields. I was using Regex to find and replace these xml tags. But I was s...

Generate words that fit in Guids (just for fun)

I have some tests that use guids. The guids used don't need to be enormously unique, they just need to be guids. Random guids are boring - so I'm trying to find fun guid words. Right now, I don't have anything better than "00000000-feed-dada-iced-c0ffee000000". Ideally I'd generate a list of verbs, nouns, prepositions. Having only spent...

How to configure my Regular Expression dot to match linebreaks?

hi all, i'm trying to figure this out: <STYLE> lots of text and linebreaks </STYLE> how can i detect ANYTHING that lies inside the style tag (incl. linebreaks)? i tried .*? but didn't help thx ...

String Matching for /* and */

Hello. I have a text file including the lines below: /* MY TXT File LINE */ /* MY TXT File LINE MORE */ constant private FileName = <A "C:\\TMP\\ALARM.TXT"> constant ConfigAlarms = <U1 0> /* Comment Here*/ I don't know how to divide the comment lines (/* something */): LINE1: /* MY TXT File */ LINE2: (acturally i don't thin...

Regex Expression for AA99 pattern

I need a regex string for validating an account code. The code is four characters that has to start with an alpha followed by an alphanumeric then followed by numerals only (i.e. AC23, D345, CT75) I currently have the following statement that will throw error if (!Regex.Match(iLineItem.Code, @"^[A-Za-z0-9][A-Za-z0-9]*$").Success) ...

retrieve all possible substring matches with n characters from a string

Basically I want to retrieve all possible substring matches with n characters from a string, Here's my initial code but it only returns 2 matches. String input = "abc12345abcd"; Regex regex = new Regex(@"[A-Za-z]{3}"); //this will only return 2 matches MatchCollection matches = regex.Matches(input); How should I get the following ma...

Replace text (change case) in a textbox using Javascript

I am trying to build a sort of intelli-sense text input box, where as the user types, the 'and' is replaced by 'AND \n' (i.e. on each 'and', the 'and' is capitalized and user goes to new line). The Javascript I used for this is: function Validate() { document.getElementById("search").value = document.getElementById("search").value.r...

Regular Expresion to match fractions and not dates

I'm trying to come up with a regular expression that will match a fraction (1/2) but not a date (5/5/2005) within a string. Any help at all would be great, all I've been able to come up with is (\d+)\/(\d+) which finds matches in both strings. Thanks in advance for the help. ...

Need help with a JavaScript regex

I am allowing to make a new field in one of my web apps, to add a product. Pushing add a product clones one of the inputs, and I set it to a blank value. I need to update the name however. The name is in this format <input type="text" name="product[0][0][3][title]" value="my product" id="input-AbGHtQS3" maxlength="150" /> I need to ...

how to check if a string contains an alphanum chars appears at least n times consecutively

I am testing for a string if it contains at least n chars in consecutive order: I have this regex but it doesn't seems to work (\w\1){3,} Can someone please help!!! Thanks ...

How to match 2 out of "1,2,7,9,13,3,10,4,21,6,12" in MySQL?

I'm not familiar with regex in MySQL. ...