Solved

Regex Pattern Question

Posted on 2014-04-07
5
400 Views
Last Modified: 2014-04-09
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.
0
Comment
Question by:WH_Tech
5 Comments
 
LVL 35

Accepted Solution

by:
Terry Woods earned 250 total points
ID: 39984563
You should be able to do a regex replace with pattern:
T\.TestString(?=, TestString)

Open in new window


The (?=...) part is a positive lookahead
0
 
LVL 84

Assisted Solution

by:ozo
ozo earned 250 total points
ID: 39984565
^T\.TestString
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39984893
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?
0
 

Author Comment

by:WH_Tech
ID: 39989094
VS 2013 (C#)
0
 
LVL 74

Expert Comment

by:käµfm³d 👽
ID: 39989117
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.
0

Featured Post

How your wiki can always stay up-to-date

Quip doubles as a “living” wiki and a project management tool that evolves with your organization. As you finish projects in Quip, the work remains, easily accessible to all team members, new and old.
- Increase transparency
- Onboard new hires faster
- Access from mobile/offline

Join & Write a Comment

Suggested Solutions

In order to hide the "ugly" records selectors (triangles) in the rowheaders, here are some suggestions. Microsoft doesn't have a direct method/property to do it. You can only hide the rowheader column. First solution, the easy way The first sol…
Do you hate spam? I do, and I am willing to bet you do as well. I often wonder, though, "if people hate spam so much, why do they still post their email addresses on the web?" I'm not talking about a plain-text posting here. I am referring to the fa…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
Explain concepts important to validation of email addresses with regular expressions. Applies to most languages/tools that uses regular expressions. Consider email address RFCs: Look at HTML5 form input element (with type=email) regex pattern: T…

746 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

10 Experts available now in Live!

Get 1:1 Help Now