views:

84

answers:

2

Where I'm running into a roadblock is trying to check for this

(?<http>(http|ftp|https):\/\/)?(?<address>([\w-]+\.)+[\w-]+(/[\w- ./?%&=]*)?)

while rejecting the expression if it contains the @ sign.

I've tried a number of variations on this with no success.

What would work is if I can tell it to make sure that there are no @ characters in it but I don't want to require a character using the [^@] syntax. So how do I tell regex to accept \w and reject @ at the same time. I can't do [\w^@] to the best of my knowledge.

My Difficulty is that I'm using regex replace. Ar you suggesting then that I use a placeholder and ten match against that afterwards?

+3  A: 

You don't have to get everything into one regex. You could for example, match against your existing regex, then check with a secondary regex that the string doesn't have an @-sign.

Ned Batchelder
Yep, does not need to be one regex for one task. Mulitple regexs are maybe clearer. Maybe this link can give some more hints: http://www.regular-expressions.info/email.html
Theo Lenndorff
A: 

I agree with Ned. Use two regular expressions. You can get them from several sources, including http://regexlib.com/

TrueWill