Find common directory path: Difference between revisions

m
→‎{{header|Java}}: Added note about adding more separators
m (→‎{{header|Java}}: Clarify comment)
m (→‎{{header|Java}}: Added note about adding more separators)
Line 624:
<pre>/home/user1/tmp/
/</pre>
Change <code>folders[i] = paths[i].split("/");</code> to add more separators. Ex: to add "\" and "." as separators, change the line to <code>folders[i] = paths[i].split("[/\\\\.]");</code> (adding square brackets makes the regex choose one character out of the group inside, adding all of the extra backslashes escapes the backslash character). After making this change, all separators will be changed to "/" in the result, but they can be mixed in the path (e.g. "/home.user1/tmp\\coverage/test" (escaped backslash) will act the same as "/home/user1/tmp/coverage/test").
 
=={{header|Liberty BASIC}}==
Anonymous user