Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Regular Expressions - replace

Status
Not open for further replies.

seantuk

Programmer
Mar 22, 2005
62
GB
the solution to this is probably quite simple, but i'm not very good with regular expressions. i have this method

Code:
public static string removeString(string target, string before)
{
  return after;//no target in my before
}

how do i use regular expressions to remove all occurences of 'target' from 'before'?

NB - there may be anywhere between zero and infinite occurences of target in before
 
Hi,
Is ther a reason why you can't just use myString.Replace(...), rather than messing about with RegExes?
 
curious about the times, how many itererations, and occurances of your pattern and what where the times.

string s_output = Regex.Replace(_input,"joe","mary",RegexOptions.IgnoreCase);
Marty
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top