Regex positive lookahead when lookahead data doesn't exist (PCRE)

خرید بک لینک

I'm trying to match out a string which will have a format similar to the following:

useame=joe password='this! is a password with "quotes" and spaces#913 custom1 customd afd weirdhuh? custom1=myvalue

To explain in more detail, this is a list of variables separated by equal signs. The valid variables that can be passed are: useame, password, and customX (where X is any number of digit(s)).

I am specifically trying to match out the password field as the passed variable can technically have any number of quotes, spaces, etc that are valid characters. I have decided that the best "break point" to use to determine when the password string terminates is the existence of a "customX=" string which infers that the next variable is starting.

Therefore, in the above example the actual password would be:

'this! is a password with "quotes" and spaces#913 custom1 customd afd weird huh?

I have arrived at the following regex:

(?i)password(?-i)=.+?(?= (?i)custom(?-i)d+=)

This appears to match the following:

password='this! is a password with "quotes" and spaces#913 custom1 customd afd weird huh?

This is in effect what I want (I can easily parse out the "password="), but the problem is this regex only seems to work if there is an existence of that final "custom1=myvalue" at the end of the string. If that is removed, then there is no match at all.

I need to be able to match the password string regardless if that final value is there or not.

Bonus points if you can strip out the "password=" to end up only with the actual password.

Recent Questions...

ما را در سایت Recent Questions دنبال می‌کنید

برچسب: نویسنده: استخدام کار بازدید: 153 تاريخ: پنجشنبه 20 خرداد 1395 ساعت: 13:35

صفحه بندی