I am trying to update hundreds of lines of comments in my php files. My editor allows me to use regular expressions to perform a search and replace. However, I don't know much about regular expression to write it. Please refer to example below.

Dump($Data1, 'Library_reports.php - Get_Filtered_InventoryReport() - $Data1');
Dump($Data2, 'Library_reports.php - Get_Filtered2InventoryReport() - $Data2');
Dump($Data3, 'Library_reports.php - GetFilteredInventoryReport() - $Data3');

to be replace with

Dump($Data1, __METHOD__.' - $Data1');
Dump($Data2, __METHOD__.' - $Data2');
Dump($Data3, __METHOD__.' - $Data3');

So basically, I want to search for

'Some_Alphanumeric_string()

and then replace it with a

__METHOD__.'

有帮助吗?

解决方案

Give it a try: [A-Za-z0-9_]() it's nothing complicated here.

Edit:

[A-Za-z0-9_]+\(\)

StackOverflow eats my backslashes :)

其他提示

Search with:

([a-zA-Z0-9]+)\(\)

Replace with:

^ intentionally left blank

Based on your description, this search regex will do the trick:

\b[a-z0-9_]+\b\(\)

...assuming you do case insensitive search. (It's an option in the Dreamweaver search/replace tool). Otherwise:

\b[A-Za-z0-9_]+\b\(\)

Note: I've included the underscore in the character class based on your use of them in:

"Some_Alphanumeric_string()"

许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top