Wednesday, June 3, 2015

Re: RegExp on TextResource

Not sure whats your problem, maybe 'multiline text' is causing the regex to fail.

Alternatively, you can use GQuery and work with the nodes instead of strings. Something like (html must start with '<')...
Gquery root = $(html);
// to read...
String pInnerHtml = root.filter(true,"#pid").html();
// to write...
root
.filter(true,"#pid").html("updated <b>content</b>");
// finally, append to the dom
root
.appendTo(somePlace);



On Saturday, May 30, 2015 at 12:04:39 PM UTC+2, Alireza Rezaei Mahdiraji wrote:

Hi All,

I am trying to apply a regular expression on a TextResource (which is an html file),

but it does not work. I can see the content of the resource as strign. If I provide the content of the file directly to RegExp it works.

String html = ReadHtmlResources.INSTANCE.
                    getDocumentationHtml().getText();

RegExp regExp = RegExp.compile("<p id='pid'>(.*?)</p>");

MatchResult matcher = regExp.exec(html);

boolean matchFound = matcher != null; // returns false


Any idea why this does not work?

Cheers,
Alireza

--
You received this message because you are subscribed to the Google Groups "Google Web Toolkit" group.
To unsubscribe from this group and stop receiving emails from it, send an email to google-web-toolkit+unsubscribe@googlegroups.com.
To post to this group, send email to google-web-toolkit@googlegroups.com.
Visit this group at http://groups.google.com/group/google-web-toolkit.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment