lookahead

PHP - REGEX - use string for pattern but exclude it from being removed!

Hi All guys! i'm pretty new on regex, i have learned something by the way, but is still pour knowledge! so i want ask you for clarification on how it work! assuming i have the following strings, as you can see they can be formatted little different way one from another but they are very similar! DTSTART;TZID="America/Chicago":2003081...

Regexp for selecting spaces between digits and decimal char

I want to remove spaces from strings where the space is preceeded by a digit or a "." and acceded by a digit or ".". I have strings like: "50 .10", "50 . 10", "50. 10" and I want them all to become "50.10" but with an unknown number of digits on either side. I'm trying with lookahead/lookbehind assertions like this: $row = str_replace("...

Does lookaround affect which languages can be matched by regular expressions?

There are some features in modern regex engines which allow you to match languages that couldn't be matched without that feature. For example the following regex using back references matches the language of all strings that consist of a word that repeats itself: (.+)\1. This language is not regular and can't be matched by a regex, which...

Regular Expression Postive Lookahead substring

I am fairly new to regular expressions and the more and more I use them, the more I like them. I am working on a regular expression that must meet the following conditions: Must start with an Alpha character Out of the next three characters, at least one must be an Alpha character. Anything after the first four characters is an automa...

Complex(?) regex: Is expression, but not another

(If you can make a better title, please do) Hi, I need to make sure a string matches the following regex: ^[0-9a-zA-Z]{1}[0-9a-zA-Z\.\-_]*$ (Starts with a letter or number, then any number of letters, numbers, dots, dashes or underscores) But given that, I need to make sure it doesn't match a Guid, my Guid matching reg-ex looks like...

How does the regular expression ‘(?<=#)[^#]+(?=#)’ work?

I have the following regex in a C# program, and have difficulties understanding it: (?<=#)[^#]+(?=#) I'll break it down to what I think I understood: (?<=#) a group, matching a hash. what's `?<=`? [^#]+ one or more non-hashes (used to achieve non-greediness) (?=#) another group, matching a hash. what's the `?=`? So the p...

Lazy Regex Match in .NET. What's wrong here?

Hi! In the following example I would like to retrieve the text between pMAINp and the first pMDSp. The regex has a look-behind and a look-ahead: string contents = "pMAINp MAP B FlightTest Load pMDSp ZutiCarrier pWingp some pMDSp more pWingp end"; string blockMainRegex = @"(?<=pMAINp)[\s\w+]+(?=(pMDS)?)"; The result I was hoping for w...

Browsers different interpretations of a regex with lookahead

I am running a split in javascript with /\s+(AND|OR)(?=\s+")\s+/ on "email" IS NOT NULL AND "email" LIKE '%gmail.com' OR "email" = '[email protected]' Now, my understanding of regular expressions would lead me to expect obtaining the following array: [0]: "email" IS NOT NULL [1]: "email" LIKE '%gmail.com' [2]: "email" = '[email protected]' ...

Regex to match tag contents while simultaneously omitting leading and trailing whitespace

I am trying to write a regex that matches entire contents of a tag, minus any leading or trailing whitespace. Here is a boiled-down example of the input: <tag> text </tag> I want only the following to be matched (note how the whitespace before and after the match has been trimmed): "text" I am currently trying to use...

Efficiency of lookarounds in C# regular expressions. Should I avoid them if I can?

Hello, everyone! I'm quite new to regular expressions, but I like them, A LOT! Call me nitpicky if you will, but I'd really like to know if I should avoid using lookaheads and lookbehinds if I have an option. For example, the two commands below do the same thing, one uses lookbehind and the other doesn't. the_str = Regex.Replace(the_s...

Regular Expressions - Match records i HTML

I have to match a large amount of records in HTML. I want each record matched with a regular expression (using .NET Regex Match). Each record is formatted like this (the total HTML contains of normal HTML and ~100 records like the following): <tr onclick="window.location.href='Vareauktion.asp?VISSER=Ja&funk=detaljedata&ID=14457'" sty...