<div dir="ltr">See inline.<br><div><div class="gmail_extra"><br><br><div class="gmail_quote">On 27 March 2014 16:59, Yuan, Stacy [DBA] <span dir="ltr"><<a href="mailto:stacyy@telenav.com" target="_blank">stacyy@telenav.com</a>></span> wrote:<br>
<blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">Hi,<br>
<br>
I am new to this area. Thank you very much for your reply!<br>
<br>
This is current script<br>
<br>
brandName matches "(?i)(.*cyber.*|.*internet.*|.*pizza.*|.*restaurant.*|.*sushi.*)<br>
<br>
So this matches every string containing sushi.<br>
<br>
Joa Sushie Café<br>
Java Sushi<br>
Sushi Blvd<br>
Japanese Sushi Bar<br></blockquote><div><br></div><div>This is to be expected: each of these 4 lines contains "sushi".<br><br> </div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
But I only want to match the word sushi. This means " Joa Sushie Café" will not be included.<br>
<br>
Actually I am looking for word match. What is the best way to include above words?<br></blockquote><div><br></div><div>All regular expressions I know have a way for expressing the concept "word boundary".<br></div>
<div>This is a zero-length assumption (or "anchor"), that matches a transition from a word character<br>to a non-word character. (Note that the definition of "word character" may not *always*<br></div>
<div>meet your expectations, but it should in this case.)<br></div><div><br><br></div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
brandName == "(?i)(.*cyber.*|.*internet.*|.*pizza.*|.*restaurant.*|.*sushi.*)???<br>
<br></blockquote><div><br></div><div>(The "==" is bad: you want to do a pattern match.) OK, to restrict the "sushi" to the <br>real thing (assuming the final "???" aren't relevant):<br><br>
</div><div> brandName matches "(?i)(...|... ...|\\bsushi\\b)"<br></div><div><br></div><div>"\b" is the word boundary anchor, and you have to duplicate the backslash, as in Java.<br> If the same borderline case should hold for pizza and others, you could use<br>
<br> brandName matches "(?i).*\\b(cyber|internet|pizza|restaurant|sushi)\\b.*"<br></div><div><br></div><div>All of this is untested, but it shouldn't be very far off the mark.<br></div><div>-W<br></div><div>
</div><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
<br>
Best<br>
<br>
Stacy<br>
<br>
-----Original Message-----<br>
From: <a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a> [mailto:<a href="mailto:rules-users-bounces@lists.jboss.org">rules-users-bounces@lists.jboss.org</a>] On Behalf Of Wolfgang Laun<br>
Sent: Thursday, March 27, 2014 12:26 AM<br>
To: Rules Users List<br>
Subject: Re: [rules-users] How to do word match in drools?<br>
<br>
You can use == to compare strings.<br>
<br>
For a more comprehensive answer, ask a more detailed question.<br>
<br>
-W<br>
<br>
On 26/03/2014, Yuan, Stacy [DBA] <<a href="mailto:stacyy@telenav.com">stacyy@telenav.com</a>> wrote:<br>
> For example, word sushi<br>
> I do not want sushie show up and shsushi show up when we do drools match.<br>
><br>
> Thanks<br>
> Stacy<br>
><br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
<br>
_______________________________________________<br>
rules-users mailing list<br>
<a href="mailto:rules-users@lists.jboss.org">rules-users@lists.jboss.org</a><br>
<a href="https://lists.jboss.org/mailman/listinfo/rules-users" target="_blank">https://lists.jboss.org/mailman/listinfo/rules-users</a><br>
</blockquote></div><br></div></div></div>