I am looking for a regex that will match a string that starts with one substring and does not end with a certain substring.
Example:
// Updated to be correct, thanks @Apocalisp
^foo.*(?<!bar)$
Should match anything that starts with "foo" and doesn't end with "bar". I know about the [^...] syntax, but I can't find anything that will ...
Easy question this time.
I'm trying to test whether or not a string does not contain a character using regular expressions. I thought the expression was of the form "[^x]" where x is the character that you don't want to appear, but that doesn't seem to be working.
For example,
Regex.IsMatch("103","[^0]")
and
Regex.IsMatch("103&","...
I know it is possible to match for the word and using tools options reverse the match. (eg. by grep -v) However I want to know if it is possible using regular expressions to match lines which does not contain a specific word, say hede?
Input:
Hoho
Hihi
Haha
hede
# grep "Regex for do not contain hede" Input
Output:
Hoho
Hihi
Haha
...
In some regex flavors, [negative] zero-width assertions (look-ahead/look-behind) are not supported.
This makes it extremely difficult (impossible?) to state an exclusion. For example "every line that does not have "foo" on it", like this:
^((?!foo).)*$
Can the same thing be achieved without using look-around at all (complexity and p...
How would I go about using a negative lookbehind(or any other method) regular expression to ignore strings that contains a specific substring?
I've read two previous stackoverflow questions:
java-regexp-for-file-filtering
regex-to-match-against-something-that-is-not-a-specific-substring
They are nearly what I want... my problem is the ...
I have something like this
aabbabcaabda
for selecting minimal group wrapped by a I have this /a([^a]*)a/ which works just fine
But i have problem with groups wrapped by aa, where I'd need something like
/aa([^aa]*)aa/ which doesn't work, and I can't use the first one like /aa([^a]*)aa/, because it would end on first occurence of ...
Hello. preg_replace ("/(\p{P})/", ' ', $str) removes apostrophes, and it should not. Please help
...
Using Ruby, how can I use a single regex to match all occurrences of 'y' in "xy y ay xy +y" that are NOT preceded by x (y, ay, +y)?
/[^x]y/ matches the preceding character too, so I need an alternative...
...
I need to get "yomomedia.com" if the HTTP_HOST is [ANY].yomomedia.com except in the cases where it is "dev.yomomedia.com" else it should return dev.yomomedia.com
echo preg_replace("/^([EVERYTHING-OTHER-THAN-DEV])\./Ui","",$_SERVER['SERVER_NAME'])
Just tried the following with no success:
echo preg_replace("/^(?!dev)\./Ui",'','www.yom...
How can I write a Regular Expression to match,
a string which does not contain the underscore "_".
...
I fairly new to regular expressions and need some help. I need to filter some lines using regex in Perl. I am going to pass the regex to another function so it needs to be done in a single line.
I want to select only lines that contain "too long"and that don't begin with "SKIPPING"
Here are my test strings:
SKIPPING this bond sinc...
This should be an easy one for the Regex experts out there... :)
I want to match any string that does not contain the string "DontMatchThis".
What's the regex?
...
I'm trying to use regular expressions to match a string that does not contain the sequence of characters of a less than symbol (<) followed by a non space. Here are some examples
Valid - "A new description."
Valid - "A < new description."
Invalid - "A <new description."
I can't seem to find the right expression to get a match. I'm usi...
Hi folks,
I would like to negate a set of words using java regex.
Say, I want to negate cvs, svn, nvs, mvc. I wrote a regex which is ^[(svn|cvs|nvs|mvc)].
Some how that seems not to be working. Could you please help? Thanks.
.\J
...
Can regular expression be utilized to match any string except a specific string constant let us say "ABC" ? Is this possible to exclude just one specific string constant? Thanks your help in advance.
...
I have a fairly long and complex HTML document, and I need to find all occurences of a given string, e.g. "foobar", unless it's between <a> and </a> anchor tags.
The trouble is: it could be inside some text between the anchor tags, e.g.
<a>this is a foobar test</a>
and even in this case, I should not find the match.
How can I do th...
I have a regex I need to match against a path like so: "C:\Documents and Settings\User\My Documents\ScanSnap\382893.pd~". I need a regex that matches all paths except those ending in '~' or '.dat'. The problem I am having is that I don't understand how to match and negate the exact string '.dat' and only at the end of the path. i.e. I...
Trying to match ONLY the first character in the sample below.
Sample string: C/C++/Objective C/Objective-C/ObjectiveC/objectiveC
My faulty regex: (?![O|o]bjective[ |-]?)C(?!\+\+)
Doh.
...
Let's say allowed_bits = ['a', 'p']
re.compile(r'<(%s)[^>]*(/>|.*?</\1>)' % ('|'.join(allowed_bits)))
matches:
<a href="blah blah">blah</a>
<p />
and not:
<html>blah blah blah</html>
What I want to do is turn it on its head, so that it matches
<html>blah blah</html>
<script type="text/javascript">blah blah</script>
and not:
...
i'm trying to do an apache rewrite where if the term "admin" is contained in the request_uri
mydomain.com/admin/anything_else
re-write the host to use a subdomain
admin.mydomain.com/admin/anything_else.
likewise, if i click a link while in the admin.mydomain.com and it is a url WITHOUT "admin" in it, then i would like to rewrite the ...