我嘗試(文字空格或製表符,然後再##)匹配一個簡單的模式P1:有條件匹配PCRE正則表達式:各種大小的lookbehind如何?
[ \t]*##\S*
但有時候,我想,以配合另一模式P2(既不空格,也不選項卡,然後再##文本):
[^ \t]*##\S*
P2時,必須使用## \ S *遵循\ S *
P1必須以其他方式使用
預期匹配資源的例子ults:
##foo
must give
##foo
##foo (6 whitespaces before pattern)
must give
##foo (because there is some whitespaces before the pattern ##foo and not any non-whitespace characters)
foo ##bar
must give
##bar (because there is some non-whitespace charecters before the pattern ##foobar)
foo bar ##foobar
must give
##foobar
我嘗試了lookbehind方法,但這是不可能的,因爲沒有固定的大小。
這將是非常好的,如果有人可以幫助我...
你想捕捉所有必須提供的字符串嗎? – anubhava