単純なパターン P1 (空白またはタブ、##、テキスト) を一致させようとしています。
[ \t]*##\S*
しかし、別のパターン P2 (空白でもタブでもなく、次に ##、次にテキスト) と一致させたい場合もあります。
[^ \t]*##\S*
##\S* が \S* に続く場合は、P2 を使用する必要があります
それ以外の場合は P1 を使用する必要があります
予想される試合結果の例:
##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
後読みメソッドを試しましたが、固定サイズがないため不可能です。
誰かが私を助けてくれたらとてもうれしいです...