How to get the previous regular expression word?

I have a path similar to this:

C: \ Development.TFS \ Examn \ R4 branch \ Web \ OrganizationManager \ Themes \ cyan \ CSS

And I need a regular expression to get the word "blue" from there. I tried, but have not yet found a solution. He practically gets the word before the last word from this line. Please help, thanks

+3
source share
5 answers
(\w+)\W+\w+$

matches the second-last word, captures it in backreference no. 1, then matches one or more non-word characters, then the last word, and then EOL.

, , ( ),

([^\\:]+)\\[^\\]+$

.

: ​​ : " ", .

+6

'\', splitResult [splitResult.Count-1]?

'\' ,

+1

: ([\w\s.-]+)\\[\w\s.-]+$. "" . .

0

if (eregi ('themes \\ ([az]. +) \\ css', $ subject)) {# Successful match} else {# Match failed}

PHP example to get the word blue.

0
source

Another option:

(\w+)\\\w+$
0
source

Source: https://habr.com/ru/post/1730169/


All Articles