Using Ruby I'm trying to split the following text with a Regex
~foo\~\=bar =cheese~monkey
Where ~ or = denotes the beginning of match unless it is escaped with \
So it should match
~foo\~\=bar
then
=cheese
then
~monkey
I thought the following would work, but it doesn't.
([~=]([^~=]|\\=|\\~)+)(.*)
What is a better regex ex...
how do i do this with regex?
i want to match this string: -myString
but i don't want to match the -myString in this string: --myString
myString is of course anything.
is it even possible?
EDIT:
here's a little more info with what i got so far since i've posted a question:
string to match:
some random stuff here -string1, --string2...
For example, in this text:
Lorem ipsum dolor sit amet, consectetur adipiscing elit. Nunc eu tellus vel nunc pretium lacinia. Proin sed lorem. Cras sed ipsum. Nunc a libero quis risus sollicitudin imperdiet.
I want to match the word after 'ipsum'.
...
Hi,
AS3 RegExp engine (and ECMAScript based JavaScript) do not support complex "lookbehind" expressions. (lookahead expressions are fully supported.)
For example:
(?<=<body>)(.*?)(?=<\/body>)
will work but;
(?<=<body\b[^>]*>)(.*?)(?=<\/body>)
will not work in AS3.
What I need is to match a complex prefix but exclude it in the ...
Hi,
I would like to extract portion of a text using a regular expression. So for example, I have an address and want to return just the number and streets and exclude the rest:
2222 Main at King Edward Vancouver BC CA
But the addresses varies in format most of the time. I tried using Lookbehind Regex and came out with this expression...
I am working on a ASP.NET response filter that rewrites URL's to point to a different domain in specific situations.
Because ASP.NET chunks the response writes, my filter gets called several times before the page is fully streamed. This means that I need to be careful that each call to Regex.Replace doesn't double replace a url (You end...
Source: <prefix><content1><suffix1><prefix><content2><suffix2>
Engine: PCRE
RegEx1: (?<=<prefix>)(.*)(?=<suffix1>)
RegEx2: (?<=<prefix>)(.*)(?=<suffix2>)
Result1: <content1>
Result2: <content1><suffix1><prefix><content2>
The desired result for RegEx2 is just <content2> but it is obviously greedy.
How do I make RegEx2 ...
I have the following regular expression in .Net
(?<=Visitors.{0,100}?"value">)[0-9,]+(?=)
and the following text
<div class="text">Visitors</div> <div class="value">14,000,000</div>
<div class="text">VisitorsFromItaly</div> <div class="value">15,200</div>
I specify in the regex either "Visitors" or "VisitorsFromItaly" and I get the...
Hi,
I am stuck at one more RegEx.
Sample input :
project description
I want to write RegEx. that if word "description" is found and its preceded by word "project" then prepend "project description" with "<project>".
expected output :
<project>project description
I wrote following Regex, n replacement string but its not working :...
First things first: Neither this, this, this nor this answered my question. So I'll open a new one.
Please read
Okay okay. I know that regexes are not the way to parse general HTML. Please take note that the created documents are written using a limited, controlled HTML subset. And people writing the docs know what they're doing. They ...
Hi folks,
I use
(?<!value=\")##(.*)##
to match string like ##MyString## that's not in the form of:
<input type="text" value="##MyString##">
This works for the above form, but not for this: (It still matches, should not match)
<input type="text" value="Here is my ##MyString## coming..">
I tried:
(?<!value=\").*##(.*)##
w...
I'm trying to write some regex that will parse information from alerts generated by Hyperic HQ. The alerts come in as emails with a subject line like:
"[HQ] !!! - Alert: My Demo Website Alert Resource: demo.myserver.net Apache Web Server State: fixed"
To cut a very long story short, I need to be able to consistently grab the "Apache W...
In the "Advanced Regular Expresssion" chapter in Mastering Perl, I have a broken example for which I can't figure out a nice fix. The example is perhaps trying to be too clever for its own good, but maybe someone can fix it for me. There could be a free copy of the book in it for working fixes. :)
In the section talking about lookaround...
Why is it counter intuitive?
/(?<!\d)\d{8}(?!\d)/,here (?<!\d) comes first,but called lookbehind,(?!\d) next,but called lookahead.All are counter intuitive.
What's the reason to name it this way?
...
This is my test-string:
<img rel="{objectid:498,newobject:1,fileid:338}" width="80" height="60" align="left" src="../../../../files/jpg1/Desert1.jpg" alt="" />
I want to get each of the JSON formed Elements inbetween the rel attribute.
It's working for the first element (objectid).
Here is my ReqEx, which works fine:
(?<=(rel="\{obj...
I am porting some functionality from a C++ application to java. This involves reading non-modifiable data files that contain regular expressions.
A lot of the data files contain regular expressions that look similar to the following:
(?<=id="VIEWSTATE".*?value=").*?(?=")
These regular expressions produce the following error:
"Look-...
I have looked at many questions here (and many more websites) and some provided hints but none gave me a definitive answer. I know regular expressions but I am far from being a guru. This particular question deals with regex in PHP.
I need to locate words in a text that are not surrounded by a hyperlink of a given class. For example, I ...
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...
Can you use backreferences in a lookbehind?
Let's say I want to split wherever behind me a character is repeated twice.
String REGEX1 = "(?<=(.)\\1)"; // DOESN'T WORK!
String REGEX2 = "(?<=(?=(.)\\1)..)"; // WORKS!
System.out.println(java.util.Arrays.toString(
"Bazooka killed the poor aardvark (yummy!)"
.sp...
Hello, I'm wondering if variable length lookbehind assertions are supported in JavaScript's RegExp engine?
For example, I'm trying to match the string "variable length" in the string "[a lot of whitespaces and/or tabs]variable length lookbehind", and I have something like this but it does not go well in various RegExp testers:
^(?<=[ ...