regex

Another regex question with ISAPI-Rewrite

Hi, it's been a couple of hours now that I'm working on this and I can't seem to figure out what the correct regex is. First of all, I'm working with IIS6 and ISAPI_Rewrite 3.0 and I'm testing my regex with the utlity that comes with it before using it on the web site. The website has an web app located at www.foo.com/bar/ and I want t...

RegEx to match on string excluding underscores

I need to check if two strings match. The first string will not contain underscores the other will. Removing the underscores from the second string would result in the strings being equivalent. Can I perform this check using the Regex.Match() method? Here is an example of what I'm looking for: my_table == mytable; db_rv_term == dbrvter...

regex for URL including query string

I thought this would be a simple google search but apparently not. What is a regex I can use in C# to parse out a URL including any query string from a larger text? I have spent lots of time and found lots of examples of ones that don't include the query string. And I can't use System.URI, because that assumes you already have the URL...

About Mercurial, .hgignore file and glob syntax

Is it possible, while using glob syntax for an .hgignore file, to recursively ignore certain files and folders, except one? Assuming that you have: a/ a/b a/c a/d Something like: syntax globe: a ^a/b This should ideally ignore c and d and keep b. I know this has been discussed in other SO questions, but it seems they're all using...

How to match comparison operators in Regex

I'm trying to create a regex that matches comparisons like this: = 445 > 5 >= 22 < 3 <= 42 <> 10 I thought that this would work, but it doesn't: [=|>|<|>=|<|<=|<>]\s\d+ It's very important that the '>' or '<' precede '='. These operators would not be valid: =< => >> << == I'm using this to create some dynamic sql so the comparis...

Search for content in functions with regex

Hello, How would I with regular expression search for functions which contains the use of a global variable without running "global $var" first? The files looks like this: class TestClass { function correctFunc() { global $var; $name = $var->name; } function invalidFuncIWantToFind() { $age ...

Python Regex to match a file in a list of files (getting error)

I'm trying to use a regex in Python to match a file (saved as a string, ie "/volumes/footage/foo/bar.mov") to a log file I create that contains a list of files. But when I run the script, it gives me this error: sre_constants.error: unbalanced parenthesis. The code I'm using is this: To read the file: theLogFile = The_Root_Path + ".pro...

A regex that converts text lists to html in PHP

Hi, I'm trying to code a regexp to convert a block of text: * List item * Another list item to html: <ul> <li>List item</li> <li>Another list item</li> </ul> I know there are snippets or classes to do this (Markdown, Textile, etc) but I think it's overkill: I really just want some basic functionality. So far I'm trying wit...

XSD regular expression pattern in .Net causes application to hang

Processing time doubles as "Y" goes to the right. Can anybody tell me why? How to solve this problem? I have many big ID's stored in a database those can't be changed so I can't limit the size too much. using System; using System.IO; using System.Text; using System.Xml; using System.Xml.Schema; namespace TestRegex { class Program { ...

Regular Expression for finding sub string

Is a regular expression the correct way of going about this? I have a list of strings (Big Ape, Big Bird, Small Bird, Small Ape, Medium Ape, Silver Ape, Blue Ape, Black Ape) if I enter 'Big' the regular expression should return (Big Ape, Big Bird), if I enter 'al' the the list that is returned is 'Small Bird, Small Ape). Is this possibl...

Regex.Split exhibiting strange behavior.

I have a regex expression that I'm doing a split against another string and I'm getting weird results. string subjectString = "Triage|Follow Up|QA"; string[] splitArray = null; try { splitArray = System.Text.RegularExpressions.Regex.Split(subjectString, @"(?<=(^|[^\\]))\|"); forea...

Ruby regular expression end of line

I am trying to find the variables in a string, e.g. "%0" can not be found. %1 Please try again %2 I need to know how each variable ends (space, period, end of line) cause I will check for the existence of same variable in the translated version of this string. Text comes from a CSV and strings do not end with a line break. I am able ...

Regular expression to extract from URI

Hi, I need a regular expression to extract from two types of URIs http://example.com/path/to/page/?filter http://example.com/path/to/?filter Basically, in both cases I need to somehow isolate and return /path/to and ?filter That is, both /path/to and filter is arbitrary. So I suppose I need 2 regular expressions for this? I am ...

Django URL configuration

Hello, I have a purchase page, it can take an optional argument as a gift, if it is a gift, the view passes a gift form to the template and if not, a regular purchase form. my old regular url, which redirects to two seperate views: (r'^(?P<item>[-\w]+)/purchase/$', 'purchase_view'), (r'^(?P<item>[-\w]+)/purchase/gift$', 'gift_view'), ...

How would I remove all <script> tags (and everything in between) from multiple files using UNIX?

I have a folder with multiple files, and I'd like to remove all <script> tags and everything in between, e.g.: This: <script type="text/javascript">function(foo);</script> As well as this: <script type="text/javascript" src="scripts.js"></script> I think in PHP it would be something like this: <?php $string = preg_replace('#(\n?<...

Boost Regex Find host/domain name

hello. I'm very new to c++ and boost. I'm trying to get the host name of a given url: this is what I have now: int main() { string url = "http://www.amazon.com/gp/product/blabla"; //Regular Expression from Javascript. boost::regex ex("/^((\w+):\/\/\/?)?((\w+):?(\w+)?@)?([^\/\?:]+):?(\d+)?(\/?[^\?#;\|]+)?([;\|])?([^\?#]+)?\??([^#]...

Using a Regex in the URI of a Mongrel Handler

Hi all, I'm currently using Mongrel to develop a custom web application project. I would like Mongrel to use a defined Http Handler based on a regular expression. For example, everytime someone calls a url like http://test/bla1.js or http://test/bla2.js the same Http handler is called to manage the request. My code so far looks a like...

What regex can I use to match any valid IP-address represented in dot-decimal notation?

What regex can I use to match any valid IP-address represented in dot-decimal notation? ...

Regular expression to ignore a certain number of character repetitions

I'm trying to write a parser that uses two characters as token boundaries, but I can't figure out the regular expression that will allow me to ignore them when I'm regex-escaping the whole string. Given a string like: This | is || token || some ||| text I would like to end up with: This \| is || token || some \|\|\| text where all...

get everything inside/between html tags

Hi, what is the best way to get some html elements + values? example: <div id="abc" class="classs"> <img src="pic1.png" alt="pico"> <img src="pic2.png" alt="nano"> </div> what I have is the id=abc of the div element. I want to get everything inside the div element like: class of the div ("classs") src of the pictures and oth...