<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">&lt;<a href="mailto:stacyy@telenav.com" target="_blank">stacyy@telenav.com</a>&gt;</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 &quot;(?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 &quot;sushi&quot;.<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 &quot; Joa Sushie Café&quot; 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 &quot;word boundary&quot;.<br></div>
<div>This is a zero-length assumption (or &quot;anchor&quot;), that matches a transition from a word character<br>to a non-word character. (Note that the definition of &quot;word character&quot; 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 == &quot;(?i)(.*cyber.*|.*internet.*|.*pizza.*|.*restaurant.*|.*sushi.*)???<br>
<br></blockquote><div><br></div><div>(The &quot;==&quot; is bad: you want to do a pattern match.) OK, to restrict the &quot;sushi&quot; to the <br>real thing (assuming the final &quot;???&quot; aren&#39;t relevant):<br><br>
</div><div>    brandName matches &quot;(?i)(...|... ...|\\bsushi\\b)&quot;<br></div><div><br></div><div>&quot;\b&quot; 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 &quot;(?i).*\\b(cyber|internet|pizza|restaurant|sushi)\\b.*&quot;<br></div><div><br></div><div>All of this is untested, but it shouldn&#39;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] &lt;<a href="mailto:stacyy@telenav.com">stacyy@telenav.com</a>&gt; wrote:<br>
&gt; For example,  word sushi<br>
&gt; I do not want sushie show up and shsushi show up when we do drools match.<br>
&gt;<br>
&gt; Thanks<br>
&gt; Stacy<br>
&gt;<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>