Training, Open Source computer languages
PerlPHPPythonMySQLApache / TomcatTclRubyJavaC and C++LinuxCSS 
Search for:
Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
 
For 2023 (and 2024 ...) - we are now fully retired from IT training.
We have made many, many friends over 25 years of teaching about Python, Tcl, Perl, PHP, Lua, Java, C and C++ - and MySQL, Linux and Solaris/SunOS too. Our training notes are now very much out of date, but due to upward compatability most of our examples remain operational and even relevant ad you are welcome to make us if them "as seen" and at your own risk.

Lisa and I (Graham) now live in what was our training centre in Melksham - happy to meet with former delegates here - but do check ahead before coming round. We are far from inactive - rather, enjoying the times that we are retired but still healthy enough in mind and body to be active!

I am also active in many other area and still look after a lot of web sites - you can find an index ((here))
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.

You can Add a comment or ranking to this page

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