Önceki soruya Asaf tarafından önerilen Yeni soru: Regex to check if exact string exists
Ben tam bir dize maç Regex veya herhangi iyi bir yöntem önerdi kullanarak başka bir dize olup olmadığını denetlemek için bir yol arıyorum. Ben bir dize başında ya da sonunda bir boşluk ya da başka herhangi bir sözcük olmayan karakter eşleştirmek için regex söyle anlıyorum. Ancak, ben bunu kurmak için tam olarak nasıl bilmiyorum.
Search String: #t
Should Match:
String 1: Hello World, Nice to see you! #t
String 2: #T Hello World, Nice to see you!
String 3: Hello World, #t Nice to see you!
Should not Match:
String 1: Hello World, Nice to see you!
String 2: Hello World, Nice to see you! #ta
String 3: #tHello World, Nice to see you!
Edit 2: daha dize örnekleri Eklenenler
Edit 1 for Serg555 and SilentGhost:
Characters allowed in search string:
#[_a-zA-Z0-9]
# is optional.
Requirements: Search String may be at any character position in the Subject. There may or may not be a white-space character before or after it. I do not want it to match if it is part of another string; such as part of a word.
For the sake of this question: I think I would do this using this pattern: /\b\#t\b/gi
However, this is not returning the results as I would have expected.
Ben kullanılarak normal dizeleri (# mevcut değildir dizeleri) için kesin sonuç bulmak mümkün duyuyorum:
/\b{$search_string}\b/gi
Ek bilgi: Bu PHP 5 kullanılacak