• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 428
  • Last Modified:

Regex Pattern Question

Is it possible to create a Regex pattern that match under the following situation?

String to Search = T.TestString
Possible Matching Search Input Strings = T.TestString, TestString

However I only want the T.TestString to match so I can replace the string.  Otherwise the replacement would be incorrect.
2 Solutions
Terry WoodsIT GuruCommented:
You should be able to do a regex replace with pattern:
T\.TestString(?=, TestString)

Open in new window

The (?=...) part is a positive lookahead
käµfm³d 👽Commented:
Are you performing the replacement in C#, or in Visual Studio (or another IDE or text editor)? If Visual Studio, what version are you using?
WH_TechAuthor Commented:
VS 2013 (C#)
käµfm³d 👽Commented:
Then what was proposed above should be fine. Earlier versions of VS had their own unique regex syntax for Find/Replace. VS 2012 and VS 2013 both use PCRE.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

7 new features that'll make your work life better

It’s our mission to create a product that solves the huge challenges you face at work every day. In case you missed it, here are 7 delightful things we've added recently to monday to make it even more awesome.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now