R
Roedy Green
Here is a regex pattern that looks for unquoted urls.
Pattern.compile( "(href|src)[ ]*=[
]*([!#\\$%&\\(\\)\\+,\\-\\./0-9:;=\\?@\\[\\]\\^_`a-z\\{\\|\\}~]+)[
that looks for things that look like this:
href=abc
href = xyz>
src=http://someplace.com/picture.jpg
However I want to avoid finding things like this:
src="http://someplace.com/picture.jpg"
I read tutorials and docs and decided this SHOULD work.
Pattern.compile( "(href|src)[ ]*=[
]*(?!"([!#\\$%&\\(\\)\\+,\\-\\./0-9:;=\\?@\\[\\]\\^_`a-z\\{\\|\\}~]+)[
It behaves just like the first one. It filters out nothing. What am I
doing wrong?
Are there tools to help debug regexes? They either work or they don't.
I have discovered nothing equivalent to a trace of debugging dumps.
All you can do is experiments on smaller strings to figure out how the
operators work.
Perhaps what's needed for the programming community are some exclusion
examples that work and don't work with notes why.
--
Roedy Green Canadian Mind Products
http://mindprod.com
To err is human, but to really foul things up requires a computer.
~ Farmer's Almanac
It is breathtaking how a misplaced comma in a computer program can
shred megabytes of data in seconds.
Pattern.compile( "(href|src)[ ]*=[
]*([!#\\$%&\\(\\)\\+,\\-\\./0-9:;=\\?@\\[\\]\\^_`a-z\\{\\|\\}~]+)[
]", Pattern.CASE_INSENSITIVE );
that looks for things that look like this:
href=abc
href = xyz>
src=http://someplace.com/picture.jpg
However I want to avoid finding things like this:
src="http://someplace.com/picture.jpg"
I read tutorials and docs and decided this SHOULD work.
Pattern.compile( "(href|src)[ ]*=[
]*(?!"([!#\\$%&\\(\\)\\+,\\-\\./0-9:;=\\?@\\[\\]\\^_`a-z\\{\\|\\}~]+)[
]", Pattern.CASE_INSENSITIVE );
It behaves just like the first one. It filters out nothing. What am I
doing wrong?
Are there tools to help debug regexes? They either work or they don't.
I have discovered nothing equivalent to a trace of debugging dumps.
All you can do is experiments on smaller strings to figure out how the
operators work.
Perhaps what's needed for the programming community are some exclusion
examples that work and don't work with notes why.
--
Roedy Green Canadian Mind Products
http://mindprod.com
To err is human, but to really foul things up requires a computer.
~ Farmer's Almanac
It is breathtaking how a misplaced comma in a computer program can
shred megabytes of data in seconds.