I am encountering a different behavior of regexp() on linux and windows using MatLab. I am trying to separate a string based on a separator. Here is a minimal example:
Linux
test_string = '<some_path>/tool/test/unit_test'
seperator = sprintf('%stest%s',filesep,filesep)
regexp(test_string, seperator,'split')
Output:
1×2 cell array
{'<some_path>/tool'} {'unit_test'}
Windows
test_string = '<some_path>\tool\test\unit_test'
seperator = sprintf('%stest%s',filesep,filesep)
regexp(test_string, seperator,'split')
Output
1×1 cell array
{'<some_path>\src\tool\test\unit_test'}
The output of this code snippet on Linux represents the behavior I want. Could anyone explain or point towards resources to understand what is going on?