Regullar expresions how to exclude some symbols

regexp
Теги: #<Tag:0x00007f7b62230700>

(Igor Zip) #1

I have a string:

https://play.google.com/store/apps/details?id=air.com.littlebigplay.games.premium.plurals&click=541255b82bc957475c7b6222d1a980a5&mysuffix={HELLO_WORLD}&optid=541255b82bc957475c7b

I need 541255b82bc957475c7b6222d1a980a5 - (I want to extract click)/ I use next regex click=(.+?)& but it take &click=541255b82bc957475c7b6222d1a980a5& .

How I can extract without “click=” and “&”?


(Максим Таран) #2

Just get group 1 from result.


(Максим Таран) #3

Or that: (?<=click=)(.+?)(?=&)


(Vasiliy Rakshin) #4

&click=([\w\W]+)&mysuffix


(Igor Zip) #5

how i can get group 1 from reslt?


(Igor Zip) #6

i need to use regex in postman

const $ = cheerio.load(pm.response.text())
var val1 = $(‘script’).text();
var val2 = val1.match("(?<=click=)([^&]+)")
console.log(val2);

pm.environment.set(’{transaction_id}’, val2)

i use that? but it is not working


(Bohdan B) #7
var str = 'https://play.google.com/store/apps/details? id=air.com.littlebigplay.games.premium.plurals&click=541255b82bc957475c7b6222d1a980a5&mysuffix={HELLO_WORLD}&optid=541255b82bc957475c7b';

var reg = /click=(\w+)&/

console.log(str.match(/click=(\w+)&/)[1]);

(Sergey Rybakin) #8
=([0-9a-f]){6,}&

(Максим Таран) #9

It’s another regex, that I have wrote. :slight_smile:


(Vasiliy Rakshin) #10

Максим, вы мой вариант из каких побуждений игнорируете?


(Максим Таран) #11

Я??? :slight_smile: Вопрос не я задавал. :slight_smile: