[Tutor] regex question

Brett Ritter swiftone at swiftone.org
Tue Jan 4 18:58:43 CET 2011


On Tue, Jan 4, 2011 at 11:07 AM, Richard D. Moores <rdmoores at gmail.com> wrote:
> A file has these 2 lines:
>
> alksdhjf ksjhdf kjshf dex akjdhf jkdshf jsdhf
> alkdshf jkashd flkjdsf index alkdjshf alkdjshf
>
> And I want the only line that contains the word "dex"

Ah! Then you want a slightly different Regex pattern.  .*dex.* would
match both lines.

You'll need to be more specific when you say "the word dex" to
determine your regex.

\sdex\s will match dex surrounded by whitespace, which might be what you want.

\bdex\b will match dex surrounded by word boundaries, which is
probably the best pick.

-- 
Brett Ritter / SwiftOne
US2003011110
swiftone at swiftone.org


More information about the Tutor mailing list