I want to make a regex that matches a word ONLY if there are a certain number of characters are ahead OR behind it. Doesn't matter what the characters are.
This is what i have so far. (?<=.{6})foo(?=.{6})
This seems to only match if there are 6+ characters behind "foo", but I want to make it so it will also match if there are 6 characters ahead as well. Sot it should be able to match both of the following examples:
this is a foo
foo this is
But it shouldn't match "foo"
Nvm I found out that this works: (?<=.{6})foo|foo(?=.{6})
I guess my question now is there a "cleaner" way of formatting it so I don't have to write "foo" twice?
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…