简体   繁体   中英

Parsing text inside brackets using regexp

I have a text in which I can not put html tags, to make links I would use syntax like wiki [go to the app](http://foo.com), I would like to extract text using regular expressions and transform the text into html. I tried using the regular expression \\[.\\) But it doesn't seems to work.

Pattern wikiLink = Pattern.compile("\\[.\\)");
Matcher mURL = wikiLink.matcher(content);
StringBuffer sb = new StringBuffer();
while (mURL.find()) {
  ...
}

If I understand your question correctly:

\[.*?\]\(http://.*?\)

this regular expression will find all text of the form

[text](http://url)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM