cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

measure splits with regex

dave_deleo
Inactive

I have URIs can have 3 qualifiers up to 7 qualifiers. The first two qualifiers are always the same /api/rx/ so I don't want to group on them. And I don't want to group on the resource file that the URI ends with. I've created a regex that allows me to group on 5 qualifiers when the URI has 7. It looks like this:

/api/rx/([^(/;\?)]*)\/([^(/;\?)]*)\/([^(/;\?)]*)\/([^(/;\?)]*)\/([^(/;\?)]*)\/.*

So a string URI: /api/rx/common/capability/v2.0/member/reminders/xyz.json

Returns a grouping of: 'common capability v2.0 member reminders'

The problem is there might not be 5 qualifiers that follow the /apr/rx/. There could be 3-5 qualifiers that follow /api/rx/. I need a way to say give me 3 to 5 qualifiers if they exist.

Does anyone have any ideas of how to do that. I'm fairly new with regex and I have been working hard at this but am stumped with this part.

Thanks,

David

2 REPLIES 2

rick_boyd
Mentor

is there always a last part you don't want to group on?

Hello David,

I would advise against using regular expression since it will cause the server slowness.

Also, use the Business Transactions if you want to have common functionality rather than depending upon URL patterns because URL patterns may change over time.

Try below expression and see if it works for you:

/api/rx/([^/]*?)?(/.*)?$

Regards, Rajesh