regex

Regex problem, matches the whole string instead of a part

I have this string: (3 + 5) * (1 + 1) I want to match this strings: (3 + 5) and (1 + 1) I used this to try to match it: (\(.*\)) But that matches the whole string, from the first ( to the last ). Any idea on how to fix this / make it working? ...

Regex working in testing program but not in .htaccess

I'm trying to redirect a URL that looks like 'accommodation/destination.php?code=108459&destination=Yang+Chum+Noi' The regex I'm using: (^accommodation/destination\.php\?code=([0-9]+)&destination=([^/]+)$) ...works fine in my regex tester but when I use it in the .htaccess file it doesn't work. Am I missing something here? ...

C# String manipulation

Hi there. I am working on an application that gets text from a text file on a page. Example link: http://test.com/textfile.txt This text file contains the following text: 1 Milk Stuff1.rar 2 Milk Stuff2.rar 3 Milk Stuff2-1.rar 4 Union Stuff3.rar What I am trying to do is as follows, to remove everything from each line, except for "w...

PHP: Time validation RegEx?

I am using following regex to validate date in format dd/mm/yyyy in php: preg_match("/([0-9]{2})\/([0-9]{2})\/([0-9]{4})/", $e_startdate, $matches) But what will be the regex to validate time in the format 10:20 PM or AM. I want a regex which will validate following format for me. <number><number><colon><number><number><space><AM or ...

Regex help with PHP

Hi, Im a newbie with regular expressions and i need some help :) I have this: $url = '<img src="http://mi.url.com/iconos/oks/milan.gif" alt="Milan">'; $pattern = '/<img src="http:\/\/mi.url.com/iconos/oks/(.*)" alt="(.*)"\>/i'; preg_match_all($pattern, $url, $matches); print_r($matches); And I get this error: Warning: preg_mat...

How to check input string with no spaces & special characters except two special charaters (that is & and Ñ)

Hi, I am trying to validate an input string (which can be copied & pasted in the textbox). The input entered should contain caps alphabates (one or more than one), numbers and two more special characters as (& and Ñ). Also there should not be any spaces in between. NB: Alphabates must present, but numbers & those two special characters ...

Regex to check only capital letters, two special characters (& and Ñ) & without any space between.

Hi, I am using below code snippet to validate my input string with: only capital letters, numbers and two special characters (those are & and Ñ) & without any space between. var validpattern = new RegExp('[^A-Z0-9\d&Ñ]'); if (enteredID.match(validpattern)) isvalidChars = true; else isvalidChars = false; Te...

help with actionscript 3 regex and xmpp stanzas

hi i have a string: <presence to="[email protected]/d9ec56e4" from="[email protected]/testsubject_2"> <x xmlns="http://jabber.org/protocol/muc#user"&gt;&lt;item affiliation="none" role="visitor"/></x></presence> how would i find out if it contains the presence attribute as well as who its from? ive tried using as3's x...

How do I turn any regex into an complement of itself without complex hand editing?

The following are pseudo examples, not real regex, but still an example of what I mean: .* (anything) -.* (NOT anything) [A-Z] (Any letter A to Z, caps only) -[A-Z] (NOT any letter A to Z, caps only) EDIT: Changed inverse into complement in the question. Here's where the change was made: "turn any regex into an complement of...

How do you write a unit test for a regex pattern?

Is it possible? Would it require a existing whitewashed and/or blacklisted datasets, or not? How would you know an exception did not exist? ...

Parse XML with jQuery

I would need to parse this: <?xml version="1.0" encoding="utf-8"?> <blamatrixrix> <name></name> <columns number="2"> <column id="title" num="0">Title</column> <column id="content" num="1">Content</column> </columns> <rows number="7"></rows> <b>Description</c> <bDescription text here</b> <b>Some title 1</b> <b>Some text blabla for Some...

How do I write a regular expression to find the following pattern?

I am trying to write a regular expression to do a find and replace operation. Assume Java regex syntax. Below are examples of what I am trying to find: 12341+1 12241+1R1 100001+1R2 So, I am searching for a string beginning with one or more digits, followed by a "1+1" substring, followed by 0 or more characters. I have the following r...

How to avoid backslash escape when writing regular expression in C/C++

For regular expression \w+\d, in many script language such as perl/python it can be written literally. But in C/C++, I must write it as: const char *re_str = "\\w+\\d"; which is ugly to eye. Is there any method to avoid it? MACRO are also acceptable. ...

DFA vs NFA engines, what is the difference in their capabilities and limitations?

Look for a non-technical explanation of the difference between DFA vs NFA engines based on their capabilities and limitations. Thanks! ...

Finding a strings in a text using regular expressions with Python

Hi, I have a text, in which only <b> and </b> has been used.for example<b>abcd efg-123</b> . Can can I extract the string between these tags? also I need to extract 3 words before and after this chunk of <b>abcd efg-123</b> string. How can I do that? what would be the suitable regular expression for this? ...

Regular Expressions - testing if a String contains another String

Suppose you have some this String (one line) 10.254.254.28 - - [06/Aug/2007:00:12:20 -0700] "GET /keyser/22300/ HTTP/1.0" 302 528 "-" "Mozilla/5.0 (X11; U; Linux i686 (x86_64); en-US; rv:1.8.1.4) Gecko/20070515 Firefox/2.0.0.4" and you want to extract the part between the GET and HTTP (i.e., some url) but only if it contain...

Regex that matches specific spaces

Hi all, I've been trying to do this Regex for a while now. I'd like to create one that matches all the spaces of a text, except those in literal string. Exemple: 123 Foo "String with spaces" Space between 123 and Foo would match, as well as the one between Foo and "String with spaces", but only those two. Thanks ...

Find replace with Regex adding extra text

I am using a regex within Visual Studio 2005 to turn my SQL statement into a readable string. I am using the find expression {.*} and the replace expression & "\1 " _. This should produce results something like: input: select * from x expected & "select * " _ & "from x " _ The reality is I am getting: & "select * " _& " "_ & "fr...

C# Replace wildcard

I am making an application to change the the resolution of that game, to the requested resolution. StreamReader reader = new StreamReader(@"C:\Documents and Settings\ARTech\Bureaublad\PersistentSymbols.ini");//Reads the file. string content = reader.ReadToEnd();//Puts the content of the file, into a variable. reader.Close(); string repl...

beginner to regex needs to change url using regular expressions

i have a url: /events/details/16-righteous-turkeys.html that i need to change to /turkeys i have no idea how to go about doing this...and would really appreciate the help. ...