[2 days left] What’s wrong with your cloud strategy? Learn why multicloud solutions matter with Nimble Storage.Register Now

x
?
Solved

Regex Pattern Question

Posted on 2014-04-07
5
Medium Priority
?
423 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
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 84

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

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

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

As most anyone who uses or has come across them can attest to, regular expressions (regex) are a complicated bit of magic. Packed so succinctly within their cryptic syntax lies a great deal of power. It's not the "take over the world" kind of power,…
The article shows the basic steps of integrating an HTML theme template into an ASP.NET MVC project
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

649 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