weekapaug
asked on
REGEX HELP
Need to capture url links from a string.
I am successfully able to filter out using this
"https://www.ANYURL.com/.*?(&)
I am looking to separate them but they are coming in separated by an ampersand.
They don't all end with the same extension and there are varying amounts of folders deep, but the one constant is that the URL ends with &
so the regex above will retrieve this.
https://www.ANYURL.com/lastfolder/&;
how can I make it recognize the end of a URL is "&" but NOT include it in the value it finds? I need it to use it as a delimiter and not display that & as part of the url
I am successfully able to filter out using this
"https://www.ANYURL.com/.*?(&)
I am looking to separate them but they are coming in separated by an ampersand.
They don't all end with the same extension and there are varying amounts of folders deep, but the one constant is that the URL ends with &
so the regex above will retrieve this.
https://www.ANYURL.com/lastfolder/&;
how can I make it recognize the end of a URL is "&" but NOT include it in the value it finds? I need it to use it as a delimiter and not display that & as part of the url
which language are you using? can you give me an example what you want to extract from the string?
ASKER
I have everything working but for the last delimiter is coming up.
So if my string is this
http://www.firstURL.com/folder1/&http://www.2ndurl.com/thisone/hasmany/folders&http://www.thirdURL/&;
I need to extract this and not have the "&" become part of my results
Right now I use this "https://www.ANYURL.com/.*?(&)
this returns
http://www.firstURL.com/folder1/&
http://www.2ndurl.com/thisone/hasmany/folders/&
http://www.thirdURL/&
So i am extracting the exact URL but my current regex is showing the result with the ampersand and I want it to look like below
http://www.firstURL.com/folder1/
http://www.2ndurl.com/thisone/hasmany/folders/
http://www.thirdURL/
I am able to manipulate later and extract that trailing ampersand but I'm pretty sure I can have a regex that will simply exclude that delimiter from the results and I am just too new to understand how.
So if my string is this
http://www.firstURL.com/folder1/&http://www.2ndurl.com/thisone/hasmany/folders&http://www.thirdURL/&;
I need to extract this and not have the "&" become part of my results
Right now I use this "https://www.ANYURL.com/.*?(&)
this returns
http://www.firstURL.com/folder1/&
http://www.2ndurl.com/thisone/hasmany/folders/&
http://www.thirdURL/&
So i am extracting the exact URL but my current regex is showing the result with the ampersand and I want it to look like below
http://www.firstURL.com/folder1/
http://www.2ndurl.com/thisone/hasmany/folders/
http://www.thirdURL/
I am able to manipulate later and extract that trailing ampersand but I'm pretty sure I can have a regex that will simply exclude that delimiter from the results and I am just too new to understand how.
What language are you using?
ASKER
coldfusion
Hi,
Can you please try like below
Can you please try like below
vals1 = "a&b&c";
vals2 = vals1.split("&");
ASKER
That wont work because there are other things in the string besides the url's.
I pretty much need my regex to do what its doing right now, except DONT show the character that is causing it to end the string value.
I pretty much need my regex to do what its doing right now, except DONT show the character that is causing it to end the string value.
That wont work because there are other things in the string besides the url's.how's your current CF code looks like?
can you provide a real example? (you can masked the domain name and important data)
perhaps you want to split using "http" as the delimiter instead? and from there on we can manipulate the individual output
can you try ?= before your delimiter like if it's '&' as delimiter then you can try like ?=(&)
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Ok, if thats the case you can use like below. I am not sure what the author is looking here. I think more information is required.
vals1 = "a&b&c";
vals2 = vals1.split("(&)");
vals1 = "a&b&c";
vals2 = vals1.split("(&)");
ASKER
Thank you this is what worked!