regex - Tcl regular expression to detect square brackets -


i have .csv files many rows have 1 of field values this:

scl[0] scl[1] scl[2] sda[1] sda[2] sda[3] 

i storing them in variable while reading csv files in line line format,like:

 set string [$m cell 0 1] 

now when regexp check whether cell has scl[0] unable pass square bracket regular expression: gave syntax:

if{[regexp "scl\[0\]" $string]} { ... } 

but if condition doesn't executed.

if in case of scl(0), i.e () instead of {} in csv file, gave {[regexp "scl\[(\]0\[)\]" $string]} worked. same format tried apply square brackets still doesn't evaluated.

am missing something?

please help.

thanks

note \ has special meaning inside double quotes. do:

regexp "scl\\[0\\]" $string 

or:

regexp {scl\[0\]} $string 

Comments

Popular posts from this blog

Spring Boot + JPA + Hibernate: Unable to locate persister -

go - Golang: panic: runtime error: invalid memory address or nil pointer dereference using bufio.Scanner -

c - double free or corruption (fasttop) -