0

I need to match "data arrival" multiple times in the string "data arrival time data arrival data arrival time data arrival data arrival time"

I have executed the below TCL code

Code:

set a "data arrival time data arrival data arrival time data arrival data arrival time"

regexp {(data arrival)*} $a match

puts $match

However i'm getting data arrival only once. Please help me out to get desired result

Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563

2 Answers2

0

You only search for 0 or more consecutive occurrences of data arrival substring with your regex.

You just need to find multiple matches, see example code:

set a {data arrival time data arrival data arrival time data arrival data arrival time}
set RE {data arrival}
set match [regexp -all -inline $RE $a]
puts $match
Wiktor Stribiżew
  • 607,720
  • 39
  • 448
  • 563
0

You need to specify that you want to search for ALL occurences that match the string. Read more here: How do I extract all matches with a Tcl regex?

Community
  • 1
  • 1
Xyzk
  • 1,332
  • 2
  • 21
  • 36