I am trying to work with Velocity, which is like programming with your feet. I'm fluent in JavaScript and PHP but not Java. So I need a little help figuring out the correct syntax for this. I've done some research but since I'm not familiar with Java and Velocity is cringy, I can't figure out the right syntax.
I have a string, $string that is a url. I need to split it at the anchor # and reorganize it so that it will be in proper form for parameters and an anchor tag.
WHAT I HAVE:
URL ($string): http://url.com#anchorlink
PARAMETERS (plain text): ?utm_campaign=abc&utm_medium=def
WHAT I'M TRYING TO DO:
Split the string at # and reconsitute the url to:
http://url.com?utm_campaign=abc&utm_medium=def#anchorlink
HERE'S WHAT I HAVE IN CODE that I need help putting into proper syntax (it's wrong here):
<div>
#set ($myArray = $string.split("#"));
<a href = "${myArray[0]}?utm_campaign=abc&utm_medium=def${myArray[1]}">
Link Text
</a>
</div>
Thanks!