Matrix Version: 5.2
Hi everyone,
I am trying to build a simple regex that will split the file name when it encounters a hyphen.
For example, the file name is
a326-bachelor-of-international-studies.pdf
I would like the regex to break the file and give me
- a326
- bachelor of international studies
As a first step, I have setup a Regex asset and specified this regex in regex asset
/[^-]*/
(I have tested this and it gives me a326)
I have an asset listing, where I am trying to print it (a326) like this
%asset_name^preg_match_result:846841^array_slice:1:1%
as its mentioned in manuals that
preg_match_result: returns regular expression matches on the returned keyword value as an array. This is the same functionality as the preg_match_all() PHP function, and should be used in conjunction with the array keyword modifiers.
All its printing is an empty array i.e. []
Slight variation %asset_name^preg_match_result:846841^array_slice:0:1% is printing
[[“a326”,"",“bachelor”,"",“of”,"",“international”,"",“studies.pdf”,""]]
I am not sure why its returning a nested array, instead of a simple array.
I have tried escaping couple of different characters ^ and - in the regex, but its not making any difference.
Also, if someone can please explain how to define a regex “replacement” and then how to use it ?