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 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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., 2022: 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