Home > Archive > PERL Beginners > February 2007 > Pattern matching
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
|
|
| Dharshana Eswaran 2007-02-21, 3:58 am |
| Hello All,
I have quite a number of strings which has some typical matches between
them. I am unable to come up with a generalised pattern for them.
Few among those strings are like this:
TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID
TAPI_TTY_NOTIFY_TTY_TONE_MSGID
TAPI_NOTIFY_CALL_LINE_INFO_MSGID
TAPI_SMS_NOTIFY_RECV_ORANGE_MOSES_SM_MSG
ID
TAPI_SIM_NOTIFY_FIXDIALING_STATUS_REFRES
HED_MSGID
TAPI_APP_ASYNC_SIM_MSG_GRPID_END
TAPI_POWER_NOTIFY_OFF_MSGID
The similarities among them are
1. All alphabets are in caps
2. It has one underscore between a grp of alphabets...
3. All the strings start from "TAPI"
Can anyone help me in getting a generalised pattern from these?
Thanks and Regards,
Dharshana
| |
|
| Does /^TAPI_([A-Z].+?_)+/ satisfy ur criteria?
- ani
Dharshana Eswaran wrote:
> Hello All,
>
> I have quite a number of strings which has some typical matches between
> them. I am unable to come up with a generalised pattern for them.
>
> Few among those strings are like this:
>
> TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID
> TAPI_TTY_NOTIFY_TTY_TONE_MSGID
> TAPI_NOTIFY_CALL_LINE_INFO_MSGID
> TAPI_SMS_NOTIFY_RECV_ORANGE_MOSES_SM_MSG
ID
> TAPI_SIM_NOTIFY_FIXDIALING_STATUS_REFRES
HED_MSGID
> TAPI_APP_ASYNC_SIM_MSG_GRPID_END
> TAPI_POWER_NOTIFY_OFF_MSGID
>
> The similarities among them are
>
> 1. All alphabets are in caps
> 2. It has one underscore between a grp of alphabets...
> 3. All the strings start from "TAPI"
>
>
>
> Can anyone help me in getting a generalised pattern from these?
>
>
> Thanks and Regards,
> Dharshana
>
> ------=_Part_1967_2931047.1172044021871--
| |
| Dr.Ruud 2007-02-21, 3:58 am |
| "Dharshana Eswaran" schreef:
> TAPI_VOICE_NOTIFY_OTHERAPP_JOINING_MSGID
> TAPI_TTY_NOTIFY_TTY_TONE_MSGID
> [...]
> Can anyone help me in getting a generalised pattern from these?
m/^ TAPI (?:_[A-Z]+)+ $/x
--
Affijn, Ruud
"Gewoon is een tijger."
| |
| Dharshana Eswaran 2007-02-21, 7:58 am |
| On 2/21/07, Dr.Ruud <rvtol+news@isolution.nl> wrote:
>
> "Dharshana Eswaran" schreef:
>
>
> m/^ TAPI (?:_[A-Z]+)+ $/x
>
> --
> Affijn, Ruud
>
> "Gewoon is een tijger."
>
> --
> To unsubscribe, e-mail: beginners-unsubscribe@perl.org
> For additional commands, e-mail: beginners-help@perl.org
> http://learn.perl.org/
>
>
> Thank you Dr.Ruud.
I just noticed one problem here,
I have a few strings which is similar to those but starts with a #TAPI_....
for eg: #TAPI_ACCE_NOTIFY_TIME_CHANGED_MSG_S
#TAPI_CPHS_NOTIFY_WAITTING_MSG_S
#TAPI_NETWORK_SIGNAL_E etc...
So i tried the same pattern as what you suggested with a little change in
it,
m/^ #TAPI (?:_[A-Z]+)+ $/x
But this is filtering both the strings starting from TAPI and the strings
starting from #TAPI.
Can i know how to filter the strings starting from #TAPI seperately and TAPI
seperately?
Thanks and Regards,
Dharshana
| |
| Dharshana Eswaran 2007-02-21, 7:58 am |
| On 2/21/07, Dharshana Eswaran <dharshana.ve@gmail.com> wrote:
>
>
>
> On 2/21/07, Dr.Ruud <rvtol+news@isolution.nl> wrote:
>
> I just noticed one problem here,
>
> I have a few strings which is similar to those but starts with a
> #TAPI_....
> for eg: #TAPI_ACCE_NOTIFY_TIME_CHANGED_MSG_S
> #TAPI_CPHS_NOTIFY_WAITTING_MSG_S
> #TAPI_NETWORK_SIGNAL_E etc...
>
> So i tried the same pattern as what you suggested with a little change in
> it,
>
> m/^ #TAPI (?:_[A-Z]+)+ $/x
>
> But this is filtering both the strings starting from TAPI and the strings
> starting from #TAPI.
>
> Can i know how to filter the strings starting from #TAPI seperately and
> TAPI seperately?
>
> Thanks and Regards,
> Dharshana
>
Sorry for this previous mail. That was a silly mistake in my code. That
works!!!!
Thanks for the help.
Regards,
Dharshana
| |
| Dr.Ruud 2007-02-22, 4:00 am |
| "Dharshana Eswaran" schreef:
> m/^ #TAPI (?:_[A-Z]+)+ $/x
>
> But this is filtering both the strings starting from TAPI and the
> strings starting from #TAPI.
Yes, "#" starts a comment, so makes the regex equivalent to m/^/, which
will allways match.
echo 'abc' |
perl -nle '
/^ # test/x and print 1
'
Either an escaping backslash, or surrounding "[]", will change that:
echo '#test' |
perl -nle '
/^ [#] test/x and print 1
'
--
Affijn, Ruud
"Gewoon is een tijger."
|
|
|
|
|