Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Regex Pattern Question

Posted on 2014-04-07
5
Medium Priority
?
425 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 1000 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 85

Assisted Solution

by:ozo
ozo earned 1000 total points
ID: 39984565
^T\.TestString
0
 
LVL 75

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 75

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

Get expert help—faster!

Need expert help—fast? Use the Help Bell for personalized assistance getting answers to your important questions.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Summary: Persistence is the capability of an application to store the state of objects and recover it when necessary. This article compares the two common types of serialization in aspects of data access, readability, and runtime cost. A ready-to…
Performance in games development is paramount: every microsecond counts to be able to do everything in less than 33ms (aiming at 16ms). C# foreach statement is one of the worst performance killers, and here I explain why.
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…
Suggested Courses

578 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