Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to put a string

Status
Not open for further replies.

tcluser16

Technical User
May 23, 2013
5
0
0
US
Hi,

I have extracted a line from a file,Now I want to put particular string from that .How to do that.Please help.

For example:
I have extracted a line
CDC Status: CDC-P1 not complete
using command
if { [ regexp "^# CDC Status:" $line ] } {
regsub -all {(\s+)} $line { } temp_sta

Now I want to set a variable to CDC-P1 not complete .

How to extract that.


Thanks
 
Hi

[ul]
[li]Your sample string contains no "#", so why [tt]regexp[/tt]'s expression includes it ?[/li]
[li]Your [tt]regsub[/tt] replaces one or more consecutive whitespace characters with one space. Why ?[/li]
[/ul]
Anyway, there is no need for the [tt]regsub[/tt] call, the [tt]regexp[/tt] alone can solve it :
Code:
[b]set[/b] line [green][i]"CDC Status: CDC-P1 not complete"[/i][/green]

[b]regexp[/b] [green][i]"^CDC Status: *(.*)"[/i][/green] [navy]$line[/navy] [teal]{}[/teal] temp_sta

[b]puts[/b] [navy]$temp_sta[/navy]


Feherke.
feherke.github.io
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top