Reputation: 47
the data in the sql column like that
BLT Salad $4.50 Ham N Cheese Panini w/Chips or Soup $3.99 Chicken Noodle Soup
I want to add <br />
after the price. (the price might change but $ will always be there) to be like that
BLT Salad $4.50
Ham N Cheese Panini w/Chips or Soup $3.99
Chicken Noodle Soup
is there is anyway to add new line after two char after the (.) or 4 char after the ($) in the price? Thanks
Upvotes: 0
Views: 461
Reputation: 4244
Dim replaced = Regex.Replace(input, "(\$\d+\.\d{2,2})", "$1<br/>")
Upvotes: 1
Reputation: 499062
Using regex, and assuming the numbers are always a $ followed by some digits, followed by a . followed by 2 digits:
Regex.Repalce(myString, "(\$\d+\.\d\d)", "$1<br />")
Breakdown of the regular expression:
( - Start capturing group
\$ - Match `$` sign
\d+ - Followed by one or more digit (replace with [0-9] if needed)
\. - Followed by a .
\d\d - Followed by two digits
) - End capturing group
Breakdown of the replacement:
$1 - Use the value of the first captured group
<br /> - Followed by <br />
Upvotes: 3