in reply to Regex - remove characters (pattern not terminated)
Thank you for all of your help! I finally got it working! However, I have another question. I'm not very familiar with lookarounds but I think that they would increase the throughput of my program exponentially!
I would like to use a lookahead (and/or lookbehind, I don't really know the difference..) assertion after matching a pattern (from a list of patterns) at either the beginning or end of the string. The lookaround would search for an adjacent pattern that is also from the list (NOTE: order does not matter!). If there is no known adjacent pattern, then remove the 6 characters preceding or following the pattern (as we have done already); if there is a pattern, proceed with some other instruction (of which is not relevant). The following is pseudocode to help explain:
$pattern_A = "123"; $pattern_b = "456"; $string_1 = "1234567890"; $string_2 = "1236547890"; # Then apply regex/lookaround to search for adjacent pattern if($adjacent_pattern == false){ remove_pattern_and_six_following_characters; print("string_*"); } else{ do_something_else; print("string_*"); }
|
|---|