Hello I was wondering if its possible to extract an ID from a URL in wappler. I want to extract the youtubeID for instance https://www.youtube.com/watch?v=jlS6NdfdaQ7z2rw what I would like to do is then extract jlS6NdfdaQ7z2rw. Is this possible?
This gives us an array of two strings, a string to the left of v= and a string to the right of v=, both strings separated by a comma. What we need to do is grab the second string.
In Data Formats right click Split and choose Array -> Last
In Data Formats choose Count and under Parameter Properties enter 1 (or true) for Count and choose Select
Hi @datguru,
Where is the URL coming from? Are you entering it manually somewhere on your page, or is it some kind of dynamic data coming from a database?
Yes Bens solutions will work, but I am thinking isnt it possible for someone to inject a post and it bypass the split if we are just using client side code?
You can format the $_POST variable (i.e. your form input) value on the server side, in your server action - directly in the insert record step. There is a server data formatter available:
I haven’t got access to the Wappler software at the moment but will check later on this afternoon. But I dont think when you click the magic wand it brings up the data formats that you get in Ben’s example? So I was wondering do you have a list of functions i.e like .split() that can be used in the expression?
Sorry Teodor… me again :D… So Split works perfectly for that usecase however the URL could come in a few different ways since its youtube it seems as though it doesn’t always have the = there. I have found a bit of regex that would work brilliantly to extract the ID but I dont see a pattern match option is there one for extracting using regex a bit like phps preg_match?
Just wondering @Teodor what the chance of getting an extract using regex is. You allow regex for validation why not for extracting into groups? It would make the data manipulation so powerful