regex

Java vs Javascript Regex problem

Hello, I am having a problem with my regular expression: <a.*href=[\"'](.*?)[\"'].*>(.*?)</a>. It is, as you can probably tell, supposed to take all the links from a string of HTML and return the link text in group 2, and the link target in group 1. But I am having a problem. If I try it in Javascript (using http://www.regextester.com/, ...

Using Perl, how can I sort an array using the value of a number inside each array element?

Let's say I have an array, @theArr, which holds 1,000 or so elements such as the following: 01 '12 16 sj.1012804p1012831.93.gz' 02 '12 16 sj.1012832p1012859.94.gz' 03 '12 16 sj.1012860p1012887.95.gz' 04 '12 16 sj.1012888p1012915.96.gz' 05 '12 16 sj.1012916p1012943.97.gz' 06 '12 16 sj.875352p875407.01.gz' 07 '12 16 sj.875408p87543...

Python regex for finding contents of mediawiki markup links

If I have some xml containing things like the following mediawiki markup: " ...collected in the 12th century, of which [[Alexander the Great]] was the hero, and in which he was represented, somewhat like the British [[King Arthur|Arthur]]" what would be the appropriate arguments to something like: re.findall([[__?__]], ar...

How do I match a Russian word in Unicode text using Perl?

I have a website I want to regexp on, say http://www.ru.wikipedia.org/wiki/perl . The site is in Russian and I want to pull out all the Russian words. Matching with \w+ doesn't work and matching with \p{L}+ retrieves everything. How do I do it? ...

Using Perl, how can I build a dynamic regexp by passing in an argument to a subroutine?

I would like to create subroutine with a dynamically created regxp. Here is what I have so far: #!/usr/bin/perl use strict; my $var = 1234567890; foreach (1 .. 9){ &theSub($_); } sub theSub { my $int = @_; my $var2 = $var =~ m/(??{$int})/; print "$var2\n"; } It looks like it will work, but it seems that once t...

SEO title making function ??

I have created a function which will convert any string into tab delimited. What's new in ASP.NET 4.0 Then it will convert above title to following: what-s-new-in-asp-net-4-0 I am using this to make my URL's SEO'd. But I am not sure that it will work fine in all cases or not. Till now I have tested this function on around 1000 rec...

What is the difference in Perl when passing a variable in a regular expression between using $variable and ${variable}

I am reviewing some ClearCase triggers written in Perl. I have noticed that in some regular expressions, variables are passed either straighforwardly or with their names in curly brackets. For example, I have the following line of code in a trigger: if ($baseline !~ /^${component}_(|.*_)$phase\.\d+(|[a-z]|-\d+|${automateddigit})$/ && ...

Regex.Replace: How to use $groups followed by numbers

With Regex::Replace we can use $1, $2, ... to match corresponding groups. But how can I use $1 followed by number. E.g. to replace 6 with 678? Regex::Replace(text, "(6)", '$178'); ...

Getting AssemblyVersion Regular Expression

I am trying to get the version number out of the AssemblyInfo.vb file and replace it with a number that I choose. Dim text as string = string.empty Using sr As New StreamReader("C:\foo\AssemblyInfo.vb") text = sr.ReadToEnd() Dim fileVerReg As New Regex("^[^']*(AssemblyVersion[(""].)([^""]*)") Dim m As Match = fileVerReg.M...

Visual Studio Find and Replace Regular Expressions

How do I match a digit in Visual Studio? My first guess: \d is not working for me. I s there a list of special characters in visual studio? ...

Javascript won't split using regex

Since I started writing this question, I think I figured out the answers to every question I had, but I thought I'd post anyway, as it might be useful to others and more clarification might be helpful. I was trying to use a regular expression with lookahead with the javascript function split. For some reason it was not splitting the st...

Regex to parse out html from CDATA with C#

Hi I would like to parse out any HTML data that is returned wrapped in CDATA. As an example <![CDATA[<table><tr><td>Approved</td></tr></table>]]> Thanks! ...

C# Regex word match extractor

ok i have a list of domains for example dogstoday . com catstoday . com petstoday . com dogsnow . org dogsabc . net catlitter . info i want a regex that will give me all domains that has the word i specify, for example dogs or cats if i give dogs it should return dogstoday.com dogsnow.org dogsabc.net can any one tell me how to d...

Restrict word list in XML schema

I'm writing an XML schema and need to prevent the text of an element from matching certain values. (Eg. the variableName element cannot match 'int', 'byte', 'string' etc.) I have tried using a restriction with a pattern element similar to "^(int|byte|string)", but without success. Do you know the way to format the regular expression, o...

New to Regular Expressions need help

I need a form with one button and window for input that will check an array, via a regular expression. And will find a exact match of letters + numbers. Example wxyz [some space btw] 0960000 or a mix of numbers and letters [some space btw] + numbers 01xg [some space btw] 0960000 The array has four objects for now. Once found i n...

Help Refining RegEx ("\b\d{6}([ ]{1,15})\d{7}\b")

In the past it was my understanding that the Lat/Lon of an airport had to be on the same line (L 300216 0915302 '2425 29865997) with 300216/0915302 being the Lat/Lon. I just found out that the users can also put the Lat/Lon on different lines. I ARA '* ACADIANA AIRPORT 29865996 ...

Finding the last (rightmost) match for an arbitrary regular expression in ruby

I'm working on a text editor in ruby, and I need to support a "Find" feature with user-provided regular expression patterns. Here's a simple (familiar) use-case: Joe User is editing a text file, and has positioned the cursor somewhere in the middle of the file. He wants to search backwards from the current cursor location for the n...

double quoting the strings inside bracket

I have a line like below. fullname = (this is a test name); I want to double quote all the strings inside "(" and ")". i.e fullname = ("this" "is" "a" "test" "name"); Can someone give me a vim regex to do that? ...

Python regex parsing

I have an array of strings in python which each string in the array looking something like this: <r n="Foo Bar" t="5" s="10" l="25"/> I have been searching around for a while and the best thing I could find is attempting to modify a HTML hyperlink regex into something that will fit my needs. But not really knowing much regex stuff I ...

python regular exp. with a unicode char

I need a reg exp that will parse something like- "2 * 240pin" where the * can be either the regular star or unicode char \u00d7 or just an x. This is what I have but its not working: multiple= r'^(\d+)\s?x|*|\\u00d7\s?(\d+)(\w{2,4})$' multiplepat= re.compile(multiple, re.I) print multiplepat.search(u'1 X 240pin').groups() returns ...