我正在尝试学习一些关于正则表达式的知识,有人可以向我解释这里发生了什么吗?并举例说明将提供预期输出的正则表达式?谢谢!
input data = 'Sometext|even more text'
regex = '(.*)?\|?.*'
replacement = '$1'
expected output = 'Sometext'
actual output = 'Sometext|even more text'
PHP
preg_filter("(.*)?\|?.*", "$1", 'Sometext|even more text'); // returns Sometext|even more text