regex

Simple Regular Expression - VB.Net

I have a syntax highlighting function in vb.net. I use regular expressions to match "!IF" for instance and then color it blue. This works perfect until I tried to figure out how to do comments. The language I'm writing this for a comment can either be if the line starts with a single quote ' OR if anywhere in the line there is two sin...

Regex Filter to Eliminate Records with AlphaNumeric Before Letter "I"

Need help narrowing the scope of this Regex to not return records if there is an alphanumeric character preceding the first "I" "I([ ]{1,2})([a-zA-Z]|\d){2,13}" Want to capture I APF From this string, but not the I ARPT. I APF 'NAPLES MUNI ARPT. ' 42894 JEB 29785584 Thanks! ...

Regex to parse querystring values to named groups

I have a HTML with the following content: ... some text ... <a href="file.aspx?userId=123&section=2">link</a> ... some text ... ... some text ... <a href="file.aspx?section=5&user=678">link</a> ... some text ... ... some text ... I would like to parse that and get a match with named groups: match 1 group["user"]=123 group["section"...

regex to match non-whitespace OR space prefixed with '\\'

I have a space delimited list of files names, where spaces in the file names are prefixed by '\' e.g. "first\ file second\ file" How can I get my regex to match each file name? ...

Why does regex "[^<]*<\\?" exhibit exponential time when the text doesn't have a "<"?

Using ICU 4.0 regex library, I find that the following regex is exhibiting exponential time: actual: "[^<]*<\?" C code: "[^<]*<\\?" Aim: find "<?" where there is no other "<" before it When running this regex on plain text with no "<" characters at all it appears to take exponential time. If the text has at least a single "<" then it...

Need a regex to exclude certain strings

I'm trying to get a regex that will match: somefile_1.txt somefile_2.txt somefile_{anything}.txt but not match: somefile_16.txt I tried somefile_[^(16)].txt with no luck (it includes even the "16" record) ...

Practical non-Turing-complete languages?

Nearly all programming languages used are Turing Complete, and while this affords the language to represent any computable algorithm, it also comes with its own set of problems. Seeing as all the algorithms I write are intended to halt, I would like to be able to represent them in a language that guarantees they will halt. Regular expre...

How do I search through a folder for the filename that matches a regular expression using Python?

I am having some difficulty writing a function that will search through a directory for a file that matches a specific regular expression (which I have compiled using 're.compile'). So my question is: How do I search through a directory (I plan to use os.walk) for a file that matches a specific regular expression? An example would be ver...

Regex/Textmate Confusion

I'm trying to create a Textmate snippet, but have run into some difficulties. Basically, I want to type in a Name and split it into its parts. Example, Bill Gates: (Bill), (bill), (Gates), (gates), (Bill Gates), (Bill gates), (bill Gates), (bill gates) EDIT** So I most certainly can produce these results quite simply if I was using ...

Finding the last occurrence of a word

I have the following string: <SEM>electric</SEM> cu <SEM>hello</SEM> rent <SEM>is<I>love</I>, <PARTITION />mind I want to find the last "SEM" start tag before the "PARTITION" tag. not the SEM end tag but the start tag. The result should be: <SEM>is <Im>love</Im>, <PARTITION /> I have tried this regular expression: <SEM>[^<]*<PARTI...

Regular expression for extracting tag attributes

I'm trying to extract the attributes of a anchor tag (<a>). So far I have this expression: (?<name>\b\w+\b)\s*=\s*("(?<value>[^"]*)"|'(?<value>[^']*)'|(?<value>[^"'<> \s]+)\s*)+ which works for strings like <a href="test.html" class="xyz"> and (single quotes) <a href='test.html' class="xyz"> but not for string without quotes: <...

how to find words within a range in a TreeSet<String> using regular expressions (java)

I am iterating though a TreeSet and printing it out: while (it.hasNext()) { System.out.println(it.next()); } output: after explorers giant hoping internet into . . . virtual world However, I would like to only print out those strings who's first character is within the range m-z. I have been playing around with java.util.regex, ...

HTML last tag conditional match

I have two strings <EM>is <i>love</i></EM>,<PARTITION /> and <EM>is <i>love</i>,<PARTITION /> I want a regex to match the second string completely but should not match the first one. Please help. Note: Everything can change except the EM and PARTITION tags. ...

Overlapping matches in Regex

Hi, I can't seem to find an answer to this problem, and I'm wondering if one exists. Simplified example: Consider a string "nnnn", where I want to find all matches of "nn" - but also those that overlap with each other. So the regex would provide the following 3 matches: nnnn nnnn nnnn I realize this is not exactly what regexes are ...

Regexps in Elisp to include newlines.

I'm trying to add a special markup to Python documentation strings in emacs (python-mode). Currently I'm able to extract a single line with: (font-lock-add-keywords 'python-mode '(("\\(\"\\{3\\}\\.+\"\\{3\\}\\)" 1 font-lock-doc-face prepend))) This works now: """Foo""" But as soon there is a newline like: """ Foo """ It ...

A Regex to sort through Sql Profiler output?

I've got a large amount (1000s of rows) of Sql Profiler (2005) output I need to sort through to find a couple of specific things. I'd like to use Regexes to do this, even though my Regex-fu is pretty weak. I'm looking for statements involving a particular temp table, which will be named something like: #ADD57L32. Unfortunately, I beli...

Checking for file-extensions in PHP with Regular expressions

I'm reading all the files in a single directory and I want to filter on JPG,JPEG,GIF and PNG. Both capital and small letters. Those are the only files to be accepted. I am currently using this: $testPics = takeFiles($picsDir, "([^\s]+(?=\.(jpg|JPG|jpeg|JPEG|png|PNG|gif|GIF))\.\2)"); and the function takeFiles looks like this: funct...

Use existing languages in BNF with TinyPG?

How can I use these BNF grammars which are in GOLD meta-syntax (RegExp + BNF) with TinyPG? I'm new to BNF so approximately what sort of conversion will I have to do to convert BNF to EBNF? I believe it should be pretty simple since TinyPG needs RegExp + EBNF in comparison to the GOLD grammars which are RegExp + BNF. Also, is there any ...

Javascript Regexp - Match string pattern except if string is inside specified tag

Hello I am trying to replace all occurences of ???some.text.and.dots??? in a html page to add a link on it. I've built this regexp that does it : \?\?\?([a-z0-9.]*)\?\?\? However, I would like to exclude any result that is inside a link : "<a ...> ... MY PATTERN ... </a>", and I am a little stuck as to how to do that, all my attempts...

Regex for matching "everything but" a string

I'm looking for a regular expression that will match all strings EXCEPT those that contain a certain string within. Can someone help me construct it? For example, looking for all strings that do not have a, b, and c in them in that order. So abasfaf3 would match, whereas asasdfbasc would not ...