0

そのようなSQL列のデータ

BLT Salad $4.50 Ham N Cheese Panini w/Chips or Soup  $3.99 Chicken Noodle Soup

<br />価格の後に追加したいです。(価格は変わるかもしれませんが、$は常にそこにあります)そのようになるために

BLT Salad $4.50
Ham N Cheese Panini w/Chips or Soup  $3.99
Chicken Noodle Soup

価格の(。)の後に2文字、または($)の後に4文字の後に改行を追加する方法はありますか?ありがとう

4

2 に答える 2

3

正規表現を使用し、数値が常に$の後にいくつかの数字が続き、その後に。が続くと仮定します。2桁が続く:

Regex.Repalce(myString, "(\$\d+\.\d\d)", "$1<br />")

正規表現の内訳:

(      - 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

交換の内訳:

$1     - Use the value of the first captured group
<br /> - Followed by <br />
于 2012-11-16T13:30:07.700 に答える
1
        Dim replaced = Regex.Replace(input, "(\$\d+\.\d{2,2})", "$1<br/>")
于 2012-11-16T13:41:18.910 に答える