1

I try to search below path using Regex.

^.*Aurix_MC-ISAR[^mak]\/port.*

But It doesn't work, so I removed expression \/

^.*Aurix_MC-ISAR[^mak]port.* <-- It works well

What is my misunderstanding point? Could you please let me know?

Target Path:D:\MCAL_SW_Test\MC-ISAR_AS4XX_AURIX_TC23X_AB_PB_BASE_V300\TC23x_ABstep\Aurix_MC-ISAR\port_infineon_tricore
ChrisP
  • 5,242
  • 1
  • 26
  • 34
Hansteve
  • 21
  • 3

2 Answers2

1

This is you regex

^.*Aurix_MC-ISAR[^mak]\/port.*

Its breakdown for your string says that

^ #Start the string
  .* #Consume everything till next string is found
  Aurix_MC-ISAR #Find this string literally
  [^mak] #Match anything except m, a or k (In your string Aurix_MC-ISAR, what follows just after it is \ which is neither m, a or k. So successful match)
  \/ #Now there is no / in your string further. So it fails here
port.* #Whatever here it won't match as it already failed

See here

NOTE :- From what I understand you are using \ in your input. So for escaping \, you need to use \\ instead of \/ which is escaping /. Though it will not make any difference in your output because there is not any extra \ after Aurix_MC-ISAR\

rock321987
  • 10,292
  • 1
  • 23
  • 36
1

Of course, that happens. [^mak] means one character that's not m, a, or k. It matches the \/ so [^mak]\/ is redundant.

And also, it should be \\ instead of \/ after seeing your path.

Aminah Nuraini
  • 13,849
  • 6
  • 73
  • 92