regex

How to find out if string contains non-alpha numeric characters in C#/.NET 2.0?

Allowed characters are (at least) A-Z, a-z, 0-9, ö, Ö, ä, ä, å, Å and german, latvian, estonian (if any) special chars? Is there ready-made method or do i have to make blacklist (non-allowed chars) and regular expressions IsMatch? If no ready-made how to use blacklist? Cheers & BR -Matti ...

Regex fix for this? [extension]

Sorry for the redundancy, I should've asked this in my previous question here: http://stackoverflow.com/questions/3061407/whats-the-regex-to-solve-this-problem This question is an extension: From the elements in an array below: http://example.com/apps/1235554/ http://example.com/apps/apple/ http://example.com/apps/126734 http://exampl...

I need a way to implement the function matches() from XPath 2.0 with functions from XPath 1.0

I have the following piece of code: root="//valueExpression[matches(self::*,'pattern')]/.." But I can only use XPath 1.0 and I get an exception for the function matches(). Can you please help me with a solution using only functions from XPath 1.0 ? ...

Regex Question..

Hello everyone- In my C# Console App I'm trying to use Regex to search a string to determine if there is a match or not. Below is my code but it is not quite working right so I will explain further. sSearchString is set to "_One-Call_Pipeline_Locations" and pDS.Name is a filename it is searching against. Using the code below it is se...

How to strip away letters from string?

I want to strip away all letters in a string, which are not numeric. Preferably a solution made with Regular Expressions or something. And in C#. How to do that? ...

Match all directory names in file path with regular expression

Can someone give me the regular expression to match something like /this/is/the/path or /this/is/the/path/ and matches like: $1=this $2=is $3=the $4=path ([^/]+)/ matches one, but I'm not quite sure how to get it to repeat. FYI: this is for a mod rewrite RewriteRule match. ...

Can mod_rewrite do math?

I am planning to convert my website to a new CMS, but I would like to use mod_rewrite to seamlessly redirect old links to their new locations. The catch is that my new blog will not have the same article numbers as the old, because I'll import some older blog entries in their first. Thus, my mod_rewrite would need to take a URL like old...

Get all text between tags with preg_match_all() or better function?

2010-June-11 <remove>2010-June-2</remove> <remove>2010-June-3</remove> 2010-June-15 2010-June-16 2010-June-17 2010-June-3 2010-June-2 2010-June-1 I'm trying to find all instances that are between the <remove> tags This is what I have: $pattern = "/<remove>(.*?)<\/remove>/"; preg_match_all($pattern, $_POST['exclude'], $matches); fore...

Day names or first 3 characters

I want my regex to catch: monday mon thursday thu ... So it's possible to write something like this: (?P<day>monday|mon|thursday|thu ... But I guess that there should be a more elegant solution. ...

Regex BBCode to HTML

I writing BBcode converter to html. Converter should skip unclosed tags. I thought about 2 options to do it: 1) match all tags in once using one regex call, like: Regex re2 = new Regex(@"\[(\ /?(?:b|i|u|quote|strike))\]"); MatchCollection mc = re2.Matches(sourcestring); and then, loop over MatchCollection using 2 pointers to find s...

Help with regex - extracting text.

I have 3 separate strings: $d = 'Created on November 25, 2009'; $v = 'Viewed 17,603 times'; $h = '1,200 hits'; Which needs to be converted to: $d1 = {unix timestamp of November 25, 2009}; $v1 = "17603"; (commas stripped if it exists) $h1 = "1200"; (commas stripped if it exists) What is the most efficient way to do this (possibly w...

/regexp?/ on HTML, but not in form

Possible Duplicate: RegEx match open tags except XHTML self-contained tags I need to do some regex replacement on HTML input, but I need to exclude some parts from filtering by other regexp. (e.g. remove all <a> tags with specific href="example.com…, except the ones that are inside the <form> tag) Is there any smart regex te...

capture text, including tags from string, and then reorder tags with text

I have the following text: abcabcabcabc<2007-01-12><name1><2007-01-12>abcabcabcabc<name2><2007-01-11>abcabcabcabc<name3><2007-02-12>abcabcabcabc<name4>abcabcabcabc<2007-03-12><name5><date>abcabcabcabc<name6> I need to use regular expressions in order to clean the above text: The basic extraction rule is: <2007-01-12>abcabcabcabc<name...

Javascript Replace text in string

I'm having some troubles getting regex to replace all occurances of a string within a string. **What to replace:** href="/newsroom **Replace with this:** href="http://intranet/newsroom This isn't working: str.replace(/href="/newsroom/g, 'href="http://intranet/newsroom"'); Any ideas? EDIT My code: str = '<A href="/newsroom/some_...

Matching n parentheses in perl regex

Hi, I've got some data that I'm parsing in Perl, and will be adding more and more differently formatted data in the near future. What I would like to do is write an easy-to-use function, that I could pass a string and a regex to, and it would return anything in parentheses. It would work something like this (pseudocode): sub parse { ...

Why are references compacted inside Perl lists?

Putting a precompiled regex inside two different hashes referenced in a list: my @list = (); my $regex = qr/ABC/; push @list, { 'one' => $regex }; push @list, { 'two' => $regex }; use Data::Dumper; print Dumper(\@list); I'd expect: $VAR1 = [ { 'one' => qr/(?-xism:ABC)/ }, { 'two' => qr/(?-xism:ABC...

Whats the regular expression for finding string between " "

Hi all, I have a string as below: "http:172.1." = (10, 1,3); "http:192.168." = (15, 2,6); "http:192.168.1.100" = (1, 2,8); The string inside " " is a Tag and inside () is the value for preceding tag. What is the regular expression that will return me: Tag: http:172.1. Value: 10, 1,3 ...

MySQL REGEXP: matching blank entries

Hi, I have this SQL condition that is supposed to retrieve all rows that satisfy the given regexp condition: country REGEXP ('^(USA|Italy|France)$') However, I need to add a pattern for retrieving all blank country values. Currently I am using this condition country REGEXP ('^(USA|Italy|France)$') OR country = "" How can achieve ...

Regex validate dates like "Sun, 20 Jun 10"

Hi, I'm working on a regular expression that will only return true when a date string is in a format something like 'ddd, dd mmm yy'. Valid matches would be values like "Sun, 20 Jun 10" or "Mon, 21 Jun 10" but not "Sunday, 20 Jun 10" or "20 Jun 10". This will be used with mb_ereg in PHP. My attempts so far have only got me half way t...

Using perl to split a line that may contain whitespace

Okay, so I'm using perl to read in a file that contains some general configuration data. This data is organized into headers based on what they mean. An example follows: [vars] # This is how we define a variable! $var = 10; $str = "Hello thar!"; # This section contains flags which can be used to modify module behavior # All modules r...