gpt4 book ai didi

c# - 使用 C# 或 Jquery 将多个
替换为单个

转载 作者:太空狗 更新时间:2023-10-30 00:00:30 24 4
gpt4 key购买 nike

里面包含多个\r\n和我用的时候

Regex.Replace(sampleText, @"[\r\n]{2,}", "<br />");

它将它更改为多个 <br>对于多个\n。我需要替换这些多个 <br><br />

Regx 之后的文字是:

Addendum 5 changes the following:<div><br></div>div<br>div&gt;&nbsp;&nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; Addenda 5 - Landscape
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>&nbsp;
<br>Item
<br>Description
<br>Qty
<br>Unit
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>Add
<br>Pavestone Hollandstone Pavers<span style="">&nbsp;<br>span&gt;
<br>Colo<br>to<br>e dark<br>own.<span style="">&nbsp;<br>span&gt;Base material not specified. Pavers to<br>e
<br>ADA compliant.
<br>478
<br>SF
<br>
<br>
<br>
<br>Area w<br>Calgary
<br>Carpet Junipe<br>is clouded on sheet L5.1. Unable to determine what changed in
<br>that area.
<br>
<br>
<br>
<br>Deduct
<br>Prunus laurocerasus 'Otto Luykens', 5 gal
<br>Otto Luykens Laurel
<br>-1
<br>EA
<br>
<br>
<br>
<br>Deduct
<br>Miscanthus sinensis<span style="">&nbsp;
<br>span&gt;'Morning Light', 5 gal
<br>Morning Light Miscanthus
<br>-3
<br>EA
<br>
<br>
<br>
<br>Add
<br>Rose 'Knockout', 5 gal
<br>Rose Knockout
<br>11
<br>EA
<br>
<br>
<br>
<br>Deduct
<br>Turf-N Tee Mulch<span style="">&nbsp;<br>span&gt;
<br>Install 1 1/2" depth mulch
<br>@ 42 sf.<span style="">&nbsp;<br>span&gt;50% fo<br>each mulch type
<br>-0.1
<br>CY
<br>
<br>
<br>
<br>Deduct
<br>Wood Shavings Mulch
<br>Install 1 1/2" depth mulch
<br>@ 42 sf.<span style="">&nbsp;<br>span&gt;50% fo<br>each mulch type
<br>-0.1
<br>CY
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>
<br>Deduct
<br>12-8-8 Gro-Power
<br>Mix into planting areas at 75
<br>lbs/1000 sf @ 42 sf pe<br>spec 329500-3.6.
<br>-3
<br>LBS
<br>
<br>
<br>
<br>Deduct
<br>5-3-1 Gro-Powe<br>Plus
<br>Mix into planting areas at 150
<br>lbs/1000 sf @ 42 sf pe<br>spec 329500-3.6.
<br>-6
<br>LBS
<br>
<br>
<br>
<br>Deduct
<br>Flou<br>of Sulfur
<br>Mix into planting areas at 20
<br>lbs/1000 sf @ 42 sf pe<br>spec 329500-3.6.
<br>-1
<br>LBS
<br>
<br>
<br>
<br>Deduct
<br>Gro-Safe Activated Charcoal
<br>Mix into planting areas at 200
<br>lbs/1000 sf @ 42 sf pe<br>spec 329500-3.6.
<br>-8
<br>LBS
<br>
<br>
<br>
<br>Deduct
<br>Plant Backfill: Compost
<br>Apply 20% compost mix and 80%
<br>native soil pe<br>detail B/L5.6.
<br>-1
<br>LS
<br>
<br>
<br>
<br>Deduct
<br>Plant Backfill: Nitrogenized
<br>Stabilized Organic Amendment
<br>Fo<br>all container-sized plants,
<br>ackfill shall<br>e a uniform mixture of the following ingredients<br>y volume):
<br>6 parts<br>y volume on-site soil, 4 parts<br>y volume nitrogen stabilized organic
<br>amendment, Grow powe<br>pe<br>manufacturers'<br>ecommendation, 2 lbs. iron sulfate
<br>pe<br>cubic yard of mix pe<br>spec 329500-3.6.
<br>-1
<br>LS
<br>
<br>
<br>
<br>Deduct
<br>Plant Backfill: 5-3-1 Gro-Power
<br>Plant Backfill: 7-5 gal @ 1 cup
<br>pe<br>specs 329500-3.6.<span style="">&nbsp;<br>span&gt;
<br>-7
<br>Cups
<br>
<br>
<br>
<br>Deduct
<br>Plant Backfill: Flou<br>of Sulfate
<br>Plant 7-5 gal @ 1/2 cup per
<br>specs 329500-3.6.<span style="">&nbsp;<br>span&gt;
<br>-3.5
<br>Cups
<br>
<br>
<br>
<br>Deduct
<br>Plant Backfill: Gro-Safe
<br>Plant Backfill:7-5 gal @ 1 cup
<br>pe<br>specs 329500-3.6.<span style="">&nbsp;<br>span&gt;
<br>-7
<br>Cups
<br>
<br>
<br>
<br>Deduct
<br>20-10-5<span style="">&nbsp;<br>span&gt;Plante<br>Tablets
<br>- 21 gram
<br>Apply to planting pits at:7-5
<br>gal @ 2 tablets pe<br>specs 329500-3.6.
<br>-14.00
<br>EA &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp; &nbsp;&nbsp;<br>div<br>div<br>div&gt;</span></span></span></span></span></span></span></span></span></span>

请帮忙,谢谢。

最佳答案

也许是这样的:

Regex.Replace(sampleText, @"[(<br( /|)>|<br( /|)>\n)]{2,}", "<br />");

应该检查 <br><br />可能\n换行符。

我没有测试过,如果<br>之间有空格可能会有一些问题换行符

关于c# - 使用 C# 或 Jquery 将多个 <br> 替换为单个 <br>,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4426716/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com