MATLAB has an in-built function isstrprop
to detect parts of a string that are either alphabet or numeric digit. The syntax is:
A = isstrprop(input_string, 'alphanum')
This is used here on each part of the split URL string.
Code
%//url_string is the given URL string
s1 = regexp(url_string,'/','Split');
out = any(cellfun(@all,isstrprop(s1(~cellfun(@isempty,s1)),'alphanum')))
Explanation
To understand the code, let's break it down into parts -
%// Input URL string
url_string = 'http://www.suleymanmemnun.com/~zeedee/9a70c0acdb2584924f5d0/web.php?#//uk/cgi-bin/confirm.php?cmd=login-submit&dispatch=0ec5d97d42ff8ff75e46c02a034bdf3bb4bf53c0db18fd85h0a134'
%// Split into parts based on '/'
split1 = regexp(url_string,'/','Split');
%// Remove the empty split parts
out_parts = split1(~cellfun(@isempty,split1))
We will get -
out_parts =
'http:' 'www.suleymanmemnun.com' '~zeedee' '9a70c0acdb2584924f5d0' 'web.php?#' 'uk' 'cgi-bin'
'confirm.php?cmd=login-submit&dispatch=0ec5d97d42ff8ff75e46c02a034bdf3bb4bf53c0db18fd85h0a134'
Next, we use isstrprop
on each of the URL parts -
out_detects = cellfun(@all,isstrprop(out_parts,'alphanum'))
It gives -
out_detects =
0 0 0 1 0 1 0 0
Finally, since you are looking to find any
such combination, we would use any
command to get the final output -
out = any(out_detects)
The final answer is 1
.
Multiple URL strings case
If you have a file that contains all the URL strings that you would like to test out for the mentioned title of the question, use this -
%// url_strings_filepath is the file that contains all the URLs line by line
url_string_array = importdata(url_strings_filepath);
out = false(1,numel(url_string_array));
for k = 1:numel(url_string_array)
s1 = regexp(char(url_string_array(k)),'/','Split');
out(k) = any(cellfun(@all,isstrprop(s1(~cellfun(@isempty,s1)),'alphanum')));
end
disp(out)