RegEx带来更多乐趣.... [英] Further Fun with RegEx....
问题描述
大家好,
这与昨天询问的有关使用RegEx为其赋予完整标题的问题有关:
正则表达式的疯狂,或如何使其可变?
通过使用ProEggNog的答案,我设法使应用程序使用
// 字符串regExp = @(?< =<).+? (?=>); //在RegEx中使用< >围绕数据
// 字符串regExp = @(?< = \ [).+?(?= \])" ;; //针对数据的[]使用RegEx
// 字符串regExp = @(?< =!).+?(?=!)";//正则表达式工作! !围绕数据
字符串 regExp = @" ).+?(?= \ " ; ?????????
但是我试图在数据周围使用",尽管我的第一个操作是将\放在前面",因为智能感知表明这是该语句的结尾",这是30分钟RegEx的Expresso应用程序教程似乎与我同意吗?任何人都除了不要使用"???
Glenn
对,是的...
试试:
字符串 regExp = @" (?< = \").+?(?= \")";在为字符串加上"@"前缀时,将变为普通的黑斜线处理
关闭,因此\不再起作用.您需要使用"代替插入单引号,并在其自身上加上反斜杠以插入反斜杠.
>
Hi All,
This is related to a question asked yesterday about the use of RegEx to give it full title:
RegEx madness, or how to make it variable?
by using ProEggNog''s answers I have managed to get the application to use
// string regExp = @"(?<=<).+?(?=>)"; //working RegEx for < > around data
// string regExp = @"(?<=\[).+?(?=\])";//working RegEx for [ ] around data
// string regExp = @"(?<=!).+?(?=!)";//working RegEx for ! ! around data
string regExp = @"(?<=\").+?(?=\")";//?????????
however I''m trying use " around the data my first though was to place \ in front of the " as the intelli-sense showed it was seeing the " as the closing " for the statement, the Expresso app for the 30 Minute RegEx tutorial seems to agree with me though? anyone any ideas apart from don''t use " ???
Glenn
Right, yes...
Try:
string regExp = @"(?<=\"").+?(?=\"")";When you prefix a string with ''@'' it turns normal blackslash processing
off, so \" doesn''t work any more. You need to use "" instead to insert a single double quote, and backslash on it''s own to insert a backslash.
这篇关于RegEx带来更多乐趣....的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!