Click here to Skip to main content
15,074,394 members
Please Sign up or sign in to vote.
3.80/5 (3 votes)
hi team, i have c# application and i am looking for answer to the issue i face
string is
newdate= "<a href="Temporarydata.aspx?name=Current transaction does not exceed $X of Credit Limit">Current Transaction should be Within $X of Credit Limit</a>"

here i am trying to remove $X from above text with different regex expressions
i tried the following options with regex

newdate = Regex.Replace(newdate, "<(.|\n)*?>", string.Empty);

newdate = Regex.Replace(newdate, @", string.Empty);

with above regex expressions i am getting the text as

"Current Transaction should be Within X of Credit Limit"

can some one guide me on the the option to get the text like

"Current Transaction should be Within $X of Credit Limit"

srinimuk 15-Jan-14 4:27am
hi my question was how to include '$' and remove the remaining html tags from the text, sorry for the confusion
also 'newdate' i use for this naming convention for this post purpose only ,i am using other name in this scenario in my application.
BillWoodruff 15-Jan-14 5:40am
does each instance of the string in 'newdate contain an actual numeric value in string form like: $1000.32, or does it, literally, contain only "X" ?
srinimuk 15-Jan-14 6:04am
Hi it contains only X like $10,$25,$19 no floating values allowed.
BillWoodruff 15-Jan-14 8:58am
So, your answer is "yes:" the character "X" does not appear, and a currency value does appear ?

The outcome you want appears to be exactly the same as the output you say your are getting now: why is that ?

1 solution

What about
Regex regex = new Regex("\\$X");
newdate = regex.Replace(newdate, string.Empty, 2);

By the way, newdate is a terrible name for that string. It does not at all contain a date, nor is it of type DateTime. See e.g. Robert C. Martin: Clean Code Chapter 2: Meaningful names (you can download it e.g. at[^])

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900