0

I want to take a string like src=' blah src='' blah and ignore the first src='

Expected results should be: blah src='' blah

I've tried: blah(?!:(src\\s*?=\\s*?))

I've seen other posts on here mentioning ^(...).*$ but I really don't understand how to apply that or really how to work with negation. The java tutorial mentions [^abc], but can that be used for a regular expression too not just characters? e.g. [^src\\s=]

user817129
  • 522
  • 3
  • 10
  • 19

1 Answers1

0

Simple "src'(.*)" should do the work unless you have more complicated cases:

Pattern pattern = Pattern.compile( "src='(.*)");
Matcher matcher = pattern.match( "src=' blah src='' blah");

if ( matcher.find( )) {
   String result = matcher.group(1); // Here is the extracted string just like you wanted.
}
Artem Barger
  • 40,769
  • 9
  • 59
  • 81
  • I think I get what you're saying here, but doesn't that also match the strings I don't want? I'm trying to apply a concept to a small example so I can understand it for when I tackle the bigger mess I need to face. – user817129 Oct 02 '13 at 06:49