Jump to content
xisto Community
buckroe2

Using The / As A Delimiter In The Split Function using the / as a Delimiter in the split function

Recommended Posts

How do I use the / as a Delimiter in the split function?

This is the code now:

($url1, $url2, $url3) = split (/\./,$Image_Upload_4);


This is what I want to be able to split up the url:
($url1, $url2, $url3) = split (/\/./,$Image_Upload_4);


I have tried to put the / in quotes but that did'nt work.

Thanks for any help.

Share this post


Link to post
Share on other sites

The split function uses Regex, so the correct method is based on the regex use of square brackets.

See here Second example is better than the first.

I am thinking the correct code for what you want to do would be something like this :

($url1, $url2, $url3) = split ([/\/./],$Image_Upload_4);

Share this post


Link to post
Share on other sites

As buckroe2 mentioned, the split character you supply is a regular expression, which can be translated into one single character or many characters. In your particular case, many different versions would work, as long as it translates into the single character /. 

 

The empty lines represent a null field caused by the double slashes // . The following expressions all translate to a single /: "/", '/', '[/]'. In a regular expression, single quotes will cause an interpretation 'as-is' without further translation. Brackets [] will enclose alternative characters, and contents of "" will be further translated according to regular expression rules.

 

Perl.org has an excellent tutorial on regular expressions that explains everything about it: http://perldoc.perl.org/perlretut.html

Share this post


Link to post
Share on other sites

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

×
×
  • Create New...

Important Information

Terms of Use | Privacy Policy | Guidelines | We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.