Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Regular expressions and special characters
#1
I am trying to find whole numbers in a string. I do not want the numbers followed by dots or dashes This following only returns the number 24.
Macro Macro7
Code:
Copy      Help
str s osr tts t
s = "INCREMENT osr_swirec swilmgrd 10.0 14-jun-2014 24 ISSUED=16-Dec-2013 \"
t = "INCREMENT nss_encryption swilmgrd 6.0 14-jun-2014 101 \"
if(findrx(s "\s\d+\s" 0 2 osr)>=0) out osr.trim
if(findrx(t "\s\d+\s" 0 2 tts)>=0) out tts.trim

While this return both 24 and 101
Macro Macro8
Code:
Copy      Help
str s osr tts t
s = "INCREMENT osr_swirec swilmgrd 10.0 14-jun-2014 24 ISSUED=16-Dec-2013 \"
t = "INCREMENT nss_encryption swilmgrd 6.0 14-jun-2014 101 a\"
if(findrx(s "\s\d+\s" 0 2 osr)>=0) out osr.trim
if(findrx(t "\s\d+\s" 0 2 tts)>=0) out tts.trim
any ideas. The special character seem to throw off quickmacros. This works find in regexbuddy. The number is a port count of a license file which constantly changes. I want to automatically pull the port count while I modify some other config files.
The only difference is in bold below. I added the a

INCREMENT nss_encryption swilmgrd 6.0 14-jun-2014 24 a\
#2
It is because of flag 2 - whole word.
Flag 2 makes the regular expression "\b\s\d+\s\b".
Characters space and \ are both non-word characters, therefore there is no word boundary.
#3
Thanks. I thought I changed the flag. But I did not.


Forum Jump:


Users browsing this thread: 1 Guest(s)