0

次の正規表現があります。

const string pattern        = "(\\w)</span>";
const string replace        = "$1&nbsp;</span>";
var rgx                     = new Regex(pattern);

そのため、 で終わり、直前に記号があるものすべてに一致します。文末に句読点があるのを除いて、同じ語句に一致させたい

例:

 Mom</span>, is awesome ....

私もそれを一致させたくありません:

Adventure is the best</span>. So now we keep on doin it ...

私は試した :

const string pattern        = "(\\w)</span>[^\\W]$";
const string pattern        = "(\\w)</span>(^\\W)$";

しかし、まったく機能しませんでした。

私が探している結果: フレーズがある場合:

Mom</span>, Dad

HTMLテキストの一部として、コンマの前にスペースを追加したくないので、一致させたくありません-> Mom 、Dad 。解析された後、ママ、パパのままにしておきたい。

しかし、私が持っていた場合:

Mom</span>and Dad (After parsing it comes like : Momand Dad)

「and」の前にスペースを追加して、解析後に「Mom and Dad」に変換できるようにします。

私がやろうとしていることを理解していただけると幸いです。

4

3 に答える 3

0
    I tried something but i could not get any direct idea. Just sharing some different method.
    Have two pattern one with punctuation and another without punctuation

    Without punctuation pattern:
        const string pattern = "(\\w)</span>([^\.\,]+)$"; (u replace with space)
    Another one with punctuation pattern:
        const string pattern = "(\\w)</span>[\,\.\\w]+$"; (u replace without space)


In both pattern add the punctuations you want at end eg. ([^\:\;]+)$
于 2013-08-19T07:12:57.233 に答える