The best place to *find* answers to programming/development questions, imo, however it's the *worst* place to *ask* questions (if your first question/comment doesn't get any up-rating/response, then u can't ask anymore questions--ridiculously unrealistic), but again, a great reference for *finding* answers.

My Music (Nickleus)

20130107

regex - how to match string, but not xxstring

(explanation of blog post title: where xx is any number of letters)

i want to find/search for all instances of "change" in a file in eclipse, but NOT match instances of "onchange":

\bchange

will match strings like:

change in:
<h:outputText value="Please change your password" />

changePwdPanel in:
oncomplete="#{rich:component('changePwdPanel')}.show()" />

BUT NOT

onchange in:
<a4j:support event="onchange" reRender="additionalConfigReqion">


\b is a word boundary

thanks to Jan Goyvaerts's post How to match whole words with a regular expression for pointing me in the right direction :)

---
search strings i googled to find the answer i was looking for:
regex match whole word
regex match string dont match certain part of the string

No comments:

Post a Comment