I am trying to write a Regex in Java. My ask is I need to split string by '/'
and get the last entry.
Looking at the discussion
REGEX IF THEN ELSE Statement
managed to write regex which is working succesfully in php i.e expression: \S*^.?((?(?=.?(\b(?:/)\b).?)\1|.)).*?$
Inputs: /etc/audit/auditd.conf, /etc/audit/rules.d/audit.rules, /etc/audisp/plugins.d/syslog.conf, /etc/httpd/conf/httpd.conf, httpd.conf, rsyslog.conf
Respective outputs: (All in Group 1) auditd.conf, audit.rules, syslog.conf, httpd.conf, httpd.conf, rsyslog.conf. but when trying to write the same in java,
same expression is returning "? The preceding token is not quantifiable" error at (?( usage in the expression, upon escaping ?
with \
, error is gone but string is not returning last string split by '/'
. Please help