Selection of useful Regex

Regex

https://myincharge.vattenfall.com.*stations

https://myincharge.vattenfall.com.*stations

URLstarts with the Portal URL contains 'stations' or 'whitelist'

/accounts/70159203/whitelist

🚧 Not recommended for stations, but for unique pages like whitelist or command editor

https://myincharge.vattenfall.com.*report.+

URL contains report but it is followed by something else, like filter queries

/accounts/70159203/stations/report/summary?filters

https://myincharge\.vattenfall\.com.*stations(\?.*)?$

URL contains stations and it is followed by query parameters, but not another path

accounts/70254191/stations

/accounts/70254191/stations?view=NETWORK

https://myincharge.vattenfall.com.*stations.report/summary.+

URL contains 'stations/report/summary'

/accounts/70159203/stations/report/summary?filter

https://myincharge.vattenfall.com.*stations/[\w-]+$

URL is of a specific station ID without any further paramters

/accounts/70159203/stations/ALF-0005158

Contains a specific word

Lets say we want a banner on the Station List page:
https://myincharge.vattenfall.com/#/accounts/70254191/stations

Idea is

  • Start with URL

  • Has some account ID in the middle that is variable

  • Has 'stations'

Regex: https://myincharge.vattenfall.com.*stations

Regex Part

Explanation

https://myincharge.vattenfall.com

Matches the exact base URL

.*

Matches any characters (including /, #, ?, etc.) between the base URL and stations.

stations

Ensures stations appears somewhere in the URL.

Tip: Go to Regex101: regex101: build, test, and debug regex

Add your Regex at the top, on the 'Flavor' select Java 8 and then add various URLs to test with

Contains a specific word and has additional text

Expanding on this page, there are additional tabs like Internet Connection ( "Network") on the Station List page. Assume the banner should be on all sub-pages, then it won't show/disappear on the Internet Connection tab

Regex: https://myincharge.vattenfall.com.*stations.+

Regex Part

Explanation

https://myincharge.vattenfall.com

Matches the exact base URL

.*

Matches any characters (including /, #, ?, etc.) between the base URL and stations.

stations

Ensures stations appears somewhere in the URL.

.+

Ensures there is at least one more character after stations, preventing it from being the last word.

Problem: Now it doesn't work with the base URL ending in 'stations'.
However, this is a great use case for e.g. Station report

Contains a Supports Query Parameters but Ensures stations is the Last Path Segment

Regex: https://myincharge.vattenfall.com.*stations(\?.*)?$

Regex Part

Explanation

https://myincharge.vattenfall.com

Matches the exact base URL

.*

Matches any characters (including /, #, ?, etc.) between the base URL and stations.

stations

Ensures stations appears somewhere in the URL.

(\?.*)?$

Allows query parameters (?view=NETWORK, ?view=CONNECTION) but ensures no additional path segments after stations.

$

Ensures the end of the URL is reached after stations or query parameters.

Finishes with a CP or Account ID

We want to add something to a CP details page: {base_url}/accounts/70159203/stations/ALF-0005158

However, the CP ID is unique.

Regex: https://myincharge.vattenfall.com.*stations/[\w-]+$

Regex Part

Explanation

https://myincharge.vattenfall.com

Matches the exact base URL

.*

Matches any characters (including /, #, ?, etc.) between the base URL and stations.

stations

Ensures stations appears somewhere in the URL.

[\w-]

Matches any word character (a-z, A-Z, 0-9, _) and hyphens (-).

+$

Asserts that the match must end here after the CP/account number. This prevents extra path segments after the account number.

Important note - check impact of Regex / URL rules

One thing is that your Regex shouldn't only work for your page, but not trigger accidentally at other pages.
if you just say 'contains the word 'station', you will match the Reports and some search pages

Copy the list of example MIP URLs below into Regex101. This way you can check if you don't accidentally trigger another URL.

//My stations

https://myincharge.vattenfall.com/#/accounts/70254191/stations

https://myincharge.vattenfall.com/#/accounts/70254191/stations?view=NETWORK

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/stations

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/stations/ALF-0005158

//Reports

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/stations/report/summary?filters

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/stations/report/history

//Whitelist

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/whitelist

//Cards

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/cards/report/summary?filters=

//Users

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/invited-users

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/user-management

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/allowances/my-allowances

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/allowances/check-card

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/search/stations

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/stations-violations?accountNumbers=70159203&businessUnits=NL

https://myincharge.vattenfall.com/#/business-unit/NL/accounts/70159203/search/stations?status=FAULTED