Regular expression greedy

I’m sure this is easy, but I tried many changes, but still can’t meet my needs. Things are too greedy, I can’t make it stop greedy.

Given the text:

test=this=that=more text follows

I want to choose:

test=

I tried the following regular expressions

(\S+)=(\S.*)
(\S+)?=
[^=]{1}
...

Thank you all.

here:

// matches "test=, test"
(\S+? )=

or

// matches "test=, test" too
(\S[^=]+)=

You should consider using the first version. Given your string “test = this = that = more text following”, version 1 will match test = this = that = and then continue to parse to the end of the string. Then it will backtrack , And find test = this =, continue backtracking, find test =, continue backtracking, and then select test = as its final answer.

Version 2 will match test = and then stop. You can use the larger I see efficiency improvements in the search, such as multi-line or entire document matching.

I am sure this is easy, but I tried many changes, but still can’t meet my needs . Things are too greedy, I can’t let it stop being greedy.

Given the text:

test=this=that=more text follows< /pre> 

I want to choose:

test=

I tried the following regular expressions

(\S+)=(\S.*)
(\S+)?=
[^=]{1}
...

Thank you all.

here:

// matches "test=, test"
(\S+? )=

or

// matches "test=, test" too
(\S[^=]+)=

You should consider using the first version. Given your string "test = this = that = more text following", version 1 will match test = this = that = and then continue to parse to the end of the string. Then it will backtrack , And find test = this =, continue backtracking, find test =, continue backtracking, and then select test = as its final answer.

Version 2 will match test = and then stop. You can use the larger See efficiency improvements in search, such as multi-line or entire document matching.

WordPress database error: [Table 'yf99682.wp_s6mz6tyggq_comments' doesn't exist]
SELECT SQL_CALC_FOUND_ROWS wp_s6mz6tyggq_comments.comment_ID FROM wp_s6mz6tyggq_comments WHERE ( comment_approved = '1' ) AND comment_post_ID = 5475 ORDER BY wp_s6mz6tyggq_comments.comment_date_gmt ASC, wp_s6mz6tyggq_comments.comment_ID ASC

Leave a Comment

Your email address will not be published.