|
||||||
| C# Programming C# (pronounced C-sharp) is a new object oriented language from Microsoft and is derived from C and C++. It also borrows a lot of concepts from Java too including garbage collection. |
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
Hi All,
I have a string in following format abc;h=v8/35bf/3/0/*/k; In above string I need to replace everything that comes between two ";" (semi colon), moreover the length between these two ";" can vary I need to replace the above string with... abc;junk; Thanks Nikesh |
| Sponsored Links |
|
|
|
|||
|
I never use Regex for replacment, just parseing. However, the lookup query will be ;*.; which will grab everything between the semicolens.
__________________
CodeCall Blog | CodeCall Wiki | Shareware | Linux Forum Chat with other CodeCall members on IRC; connect to irc.codecall.net and join #codecall |
|
|||
|
I agree with TkTech, I wouldn't use regex to do what you want to do. I would do something like this:
Code:
private string replace(string value)
{
string[] valueSplit = value.Split(';');
valueSplit[1] = "junk";
return String.Join(";", valueSplit);
}
Code:
private string replace(string value)
{
System.Text.RegularExpressions.Regex regex = new System.Text.RegularExpressions.Regex(";.*;");
return regex.Replace(value, ";junk;");
}
|
![]() |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | Search this Thread |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| need help in counting a specify character in a string. | lichy | Perl | 2 | 06-27-2007 11:03 PM |
| [Help] String manipulation. | afiser | Visual Basic Programming | 1 | 05-31-2007 04:24 PM |
| Tutorial: C# Regex | NeedHelp | CSharp Tutorials | 2 | 05-01-2007 07:44 AM |
| Accessing a string by array | Saint | C# Programming | 3 | 10-03-2006 08:33 PM |
| regex (yuck) | John | PHP Forum | 9 | 08-09-2006 01:35 AM |
| WingedPanther | ........ | 2753.6 |
| Xav | ........ | 2704 |
| Brandon W | ........ | 1702.32 |
| John | ........ | 1207.73 |
| marwex89 | ........ | 1175.24 |
| morefood2001 | ........ | 966.05 |
| dcs | ........ | 655.75 |
| Steve.L | ........ | 475.59 |
| orjan | ........ | 418.58 |
| Aereshaa | ........ | 383.54 |
Goal: 100,000 Posts
Complete: 97%