简体   繁体   中英

Regex: Extract string between two strings

This is the issue I face

The String

nt/sign-in?wa=wsignin1.0&wtre


The Need

From that string I need to extract the following

  • wsignin1.0


The Attempts

So far I have tried the following Regex

wa=(.*?)(?=&amp)

This returns:

wa=wsignin1.0

The "wa=" is not supposed to be there

Perhaps with a look behind?

(?<=wa\=)(.+)(?=\&wtre)

wsignin1.0

JMeter uses Perl5-style regular expressions therefore the regex you are looking for might be as simple as:

wa=(.+?)&wtre

Demo:

正则表达式 URL 提取

Use $1$ as "Template" in your Regular Expresssion Extractor.

See How to Debug your Apache JMeter Script for more details on JMeter tests troubleshooting.

=([\w.]++)

will capture it in the first capture group. Otherwise I think @jivan has a good idea with the lookbehind. A little tweak too it:

(?<==)[\w.]++

Put this in your Regular Expression extractor:

nt/sign-in?wa=([a-zA-Z0-9\.]*)&wtre

在此处输入图片说明 I hope this help you.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM