Reputation: 2564
I read in the contents of a file i then search for this string
00:00:00" group="MAM
and remove it !.
This is the full line that the string is on
<Field name="original_transmission_date" value="20/01/1969 00:00:00" group="MAM" />
so after I string.replace it ends up .
<Field name="original_transmission_date" value="20/01/1969 " />
My problem is that little space you see between the 9 and the " , trying to think of ways to get at it, the values and date will change but I could regex from value= onwards but I am not great with regex and it seems over kill for a whitespace!.
Any Ideas?.
Upvotes: 0
Views: 240
Reputation: 3542
you can use string.trim to remove white space , also you can use string.TrimEnd
char[] charsToTrim = { ' ' };//here you can any character to trim
myString = myString.TrimEnd(charsToTrim);
Upvotes: 0
Reputation: 2116
Quick fix if the group is always the last tag:
Replace [00:00:00" group="MAM" /] with /
Upvotes: 0
Reputation: 54618
You question is a little fuzzy and may be an XY Problem.
Are you retrieving this data or setting this data? Is this XML? Most likely there is a better solution not using REGEX at all.
Worst case scenario what not just do something simple like:
.Replace(" 00:00:00\" group=\"MAM", "").Replace("00:00:00\" group=\"MAM", "")
.
Upvotes: 3
Reputation: 273179
Your replace string should also contain the space, ie " 00:00:00\" group=\"MAM"
Upvotes: 1