Hi guys i’m trying to retrieve the link between this two tag eg text here it will then store it in a list, how do i retrieve those text with the pattern and matcher
public void getlinks() {
Pattern Start = Pattern.compile(this.PatternStart); //<Link>
Pattern End = Pattern.compile(this.PatternEnd); //</Link>
Matcher mStart = Start.matcher(this.Source); // matches Start
Matcher mEnd = End.matcher(this.Source); // matches end
????????????
}
Trying to find the link between and inside a html source, just using as an example
In general you do like this:
where
<tagstart>and<tagend>are your starting and ending tags. Thematcher.group(1)gives you everything between the tags, wherematcher.group()ormatcher.group(0)would give you the tags too.Note that it is important to use the
(.*?)if you have a text with multiple tag pairs, otherwise this will match the first<tagstart>and the last<tagend>and return everything in between.An example usage would be:
which prints