![]() |
Telelogic DOORS (steve huntington) | ![]() |
new topic :
profile :
search :
help :
dashboard :
calendar :
home
|
||
Latest News:
|
|
Topic Title: Matching strings Topic Summary: Incorrect matching of a substring Created On: 18-Aug-2005 22:58 Status: Post and Reply |
Linear : Threading : Single : Branch |
![]() |
![]()
|
![]() Answer: I think it's a simple one: regular expressions treat '.' as 'match any character'. You need to escape the '.' to match an actual period. So swap your line: Regexp line1 = regexp fig_string1"([0-9]+)(.|-)([0-9]+)(.)([0-9]+)\\b" for Regexp line1 = regexp fig_string1"([0-9]+)(\.|-)([0-9]+)(\.)([0-9]+)\\b" and it should work as you expect. Paul. | |
![]() |
|
I'm trying to match a substring in a string but keep getting incorrect matching results. My code looks like the following: for o in current Module do |
|
![]() |
|
![]() |
|
I think it's a simple one: regular expressions treat '.' as 'match any character'. You need to escape the '.' to match an actual period. So swap your line:
Regexp line1 = regexp fig_string1"([0-9]+)(.|-)([0-9]+)(.)([0-9]+)\\b" for Regexp line1 = regexp fig_string1"([0-9]+)(\.|-)([0-9]+)(\.)([0-9]+)\\b" and it should work as you expect. Paul. ------------------------- Paul dot Tiplady at TRW dot com TRW Automotive |
|
![]() |
|
![]() |
|
I see what you mean. When I took your suggestion, I received a "badly formed token" error. But, when I (\\.) instead of (\.), it worked fine. Thanks for pointing me in the right direction, Paul.
|
|
![]() |
Telelogic DOORS
» DXL Exchange
»
Matching strings
|
![]() |
FuseTalk Standard Edition v3.2 - © 1999-2009 FuseTalk Inc. All rights reserved.