Training, Open Source
computer languages


PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 

Search our site for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
Regexp help

Posted by Yash (Yash), 2 March 2007
Hello frnz,

I have string  like "e59ff020        [e59ff020]:  00000000     ...."

I want the only 00000000 as my output.. whole content from start to end may vary with different contents but before the required output we can match colon and 2 spaces [:  ]

I am new to this TCl scripting language   ,  Could any one of you give me program for this?

Thanks a lot in advance.  

Yash

Posted by admin (Graham Ellis), 4 March 2007
I think you need something like:

Code:
set inval {e59ff020        [e59ff020]:  00000000     ....}
regexp {:  ([0-9]+)} $inval all part
puts $part


Posted by Yash (Yash), 6 March 2007
Thank you Graham,  

I am facing one more problem now.
Actually i am geting below output from one of the expression like set inval [dw $yash_dfar 1]
( dw is the proc written which returns output as below)

e59ff020 [e59ff020]: 0000a0F0 ....

Below program which you have given will work only when we assign group of characters to inval manually.

regexp {: ([0-9]+)} $inval all part

So i want program for this,

======================================

Also comparision data should compare for A-F or a-f,

Could you please give me solution for this...

Thanks a lot in advance
Yash





Posted by admin (Graham Ellis), 7 March 2007
Once you've got a string in a variable, it shouldn't matter where it came from, so the trick / problem really isn't just "manually assigned works". Perhaps you have som tab characters in your incoming string?

In a regular expression character group you can add whatever you need in the square brackets - e.g.  [0-9a-fA-F].   Looking at your original post, it wasn't clear to me that you were matching hex zeros - they looked very much like decimal zeros to me



This page is a thread posted to the opentalk forum at www.opentalk.org.uk and archived here for reference. To jump to the archive index please follow this link.


WELL HOUSE CONSULTANTS LTD.: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho