I want to extract with a regex the value after ajaxBrowserNavigationCheck('&x and before the = from the following javascript code:
我想用一个正则表达式提取ajaxBrowserNavigationCheck之后的值('&x和=之前的以下javascript代码:
if (ajaxBrowserNavigationCheck('&x909ef93d-61ac-4311-ac56-20c2ae9770f5=7ebdc2a4-df58-4c1c-9b50-96964c93e927', '', 'servletcontroller', '')){
processBrowserNavigationButton();
Basicly teh value I want to extra are &x909ef93d-61ac-4311-ac56-20c2ae9770f5 (the value before the = and we need the &x) and 7ebdc2a4-df58-4c1c-9b50-96964c93e927 (the value after the =)
我希望额外的基本值是&x909ef93d-61ac-4311-ac56-20c2ae9770f5(=之前的值,我们需要&x)和7ebdc2a4-df58-4c1c-9b50-96964c93e927(=之后的值)
Note that the value is there twice (its after MODE=BROWSER_NAV) Note that both value have 36 char without the &x the &x is always there for the first string My reg ex is a bit rusty here what I got so far: (&x([0-9a-fA-F]|-)+) get me the first part
请注意,该值有两次(在MODE = BROWSER_NAV之后)注意,两个值都有36个字符而没有&x&x总是存在第一个字符串我的reg ex在这里有点生锈我到目前为止:(&x( [0-9a-fA-F] | - )+)给我第一部分
(&x([0-9a-fA-F]|-)+)|(=([0-9a-fA-F]|-)+) get me both but with the = we don't want it...
(&x([0-9a-fA-F] | - )+)|(=([0-9a-fA-F] | - )+)得到我两个但是=我们不想要它... 。
Edit: Sorry that I forgot the language, it's for a jmeter script which use jakarta ORO.
编辑:对不起,我忘记了语言,它是使用jakarta ORO的jmeter脚本。
Edit2: I realize I can split those in two variable or even in three in jmeter that make it a bit easier.
编辑2:我意识到我可以将它们分成两个变量,甚至三个用jmeter,这样可以更容易一些。
Edit3: I removed the window location part because it was misleading since it was the same in the ajax part. in ajaxBrowserNavigationCheck('&x909ef93d-61ac-4311-ac56-20c2ae9770f5=7ebdc2a4-df58-4c1c-9b50-96964c93e927', '', 'servletcontroller', '')) we want &x909ef93d-61ac-4311-ac56-20c2ae9770f5 and 7ebdc2a4-df58-4c1c-9b50-96964c93e927
编辑3:我删除了窗口位置部分,因为它有误导性,因为它在ajax部分是相同的。在ajaxBrowserNavigationCheck('&x909ef93d-61ac-4311-ac56-20c2ae9770f5 = 7ebdc2a4-df58-4c1c-9b50-96964c93e927','','servletcontroller',''))我们想要&x909ef93d-61ac-4311-ac56-20c2ae9770f5和7ebdc2a4- df58-4c1c-9b50-96964c93e927
1 个解决方案
#1
1
You haven't said what language you are using, so it's hard to give a solid answer.
你还没有说过你使用的语言,所以很难给出一个可靠的答案。
This matches just your targets:
这只匹配你的目标:
&x[a-fA-F0-9-]*(?==)
The last term is a look ahead, which asserts, but does not capture, an equals sign.
最后一个术语是向前看,它断言但不捕获等号。
This regex matches all the input and captures each target twice as groups 1 and 2:
此正则表达式匹配所有输入并将每个目标捕获两次作为组1和2:
(?m).*?(&x[a-fA-F0-9-]*)=.*(&x[a-fA-F0-9-]*)=.*
See a live demo on rubular
观看rubular的现场演示
#1
1
You haven't said what language you are using, so it's hard to give a solid answer.
你还没有说过你使用的语言,所以很难给出一个可靠的答案。
This matches just your targets:
这只匹配你的目标:
&x[a-fA-F0-9-]*(?==)
The last term is a look ahead, which asserts, but does not capture, an equals sign.
最后一个术语是向前看,它断言但不捕获等号。
This regex matches all the input and captures each target twice as groups 1 and 2:
此正则表达式匹配所有输入并将每个目标捕获两次作为组1和2:
(?m).*?(&x[a-fA-F0-9-]*)=.*(&x[a-fA-F0-9-]*)=.*
See a live demo on rubular
观看rubular的现场演示