0

[^A-Za-z0-9]テント[^A-Za-z0-9] ..?+*の複数の組み合わせで試しました

[^ |[^A-Za-z0-9] ]テント[[^A-Za-z0-9] |$]のようなものもあります

一致させたい:

  • 注意-いいえ
  • テントを見てください-はい
  • テントはいいです-はい
  • 何かテント何か-はい
  • キャンプ、テント、屋外-はい(英数字以外の区切り文字もあります)

それが簡単になれば、「テンティング」のようなものも一致する可能性があります

私が見たすべてのページから何かが欠けていると思いますが、私は本当にここで立ち往生しています。文または区切りリストの先頭、途中、または末尾で検索語を見つける必要があります。複数のステートメントを実行する必要がありますか?

この式を使用すると言う方法があるかもしれないと思っていましたが、それが行の始まりまたは行の終わりである場合はそうではありません

4

1 に答える 1

3

with \w(英数字以外)

SQL> select str
  2    from (select 'attention' str from dual union all
  3          select 'look at the tent' str from dual union all
  4          select 'tent''s are nice' str from dual union all
  5          select 'something tent something' str from dual union all
  6          select 'camping,tent,outdoors' str from dual)
  7   where REGEXP_LIKE(str, '(\W|^)tent(\W|$)', 'i') ;

STR
------------------------
look at the tent
tent's are nice
something tent something
camping,tent,outdoors

SQL> select str,
  2         case when REGEXP_LIKE(str, '(\W|^)tent(\W|$)', 'i') then 'YES' else 'NO' end matches
  3    from (select 'attention' str from dual union all
  4          select 'look at the tent' str from dual union all
  5          select 'tent''s are nice' str from dual union all
  6          select 'something tent something' str from dual union all
  7          select 'tent' str from dual union all
  8          select 'camping,tent,outdoors' str from dual);

STR                      MAT
------------------------ ---
attention                NO
look at the tent         YES
tent's are nice          YES
something tent something YES
tent                     YES
camping,tent,outdoors    YES
于 2013-02-05T17:21:21.927 に答える