Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Notifications
Login / Register
Community
Community
Notifications
close
  • Forums
  • Knowledge Center
  • Events & Webinars
  • Ideas
  • Blogs
Help
Help
  • Explore Community
  • Get Started
  • Ask the Community
  • How-To & Best Practices
  • Contact Support
Login / Register
Sustainability
Sustainability

Join our "Ask Me About" community webinar on May 20th at 9 AM CET and 5 PM CET to explore cybersecurity and monitoring for Data Center and edge IT. Learn about market trends, cutting-edge technologies, and best practices from industry experts.
Register and secure your Critical IT infrastructure

SEAL Script: Search and Replace Regular Expressions Quickstart

EcoStruxure SEAL Forum

This forum is for engineers working EcoStruxure Building Operation, wanting to leverage the SEAL application to improve the efficiency in the engineering process.

cancel
Turn on suggestions
Auto-suggest helps you quickly narrow down your search results by suggesting possible matches as you type.
Showing results for 
Show  only  | Search instead for 
Did you mean: 
  • Home
  • Schneider Electric Community
  • EcoStruxure Building
  • EcoStruxure SEAL Forum
  • SEAL Script: Search and Replace Regular Expressions Quickstart
Options
  • Subscribe to RSS Feed
  • Mark Topic as New
  • Mark Topic as Read
  • Float this Topic for Current User
  • Bookmark
  • Subscribe
  • Mute
  • Printer Friendly Page
Invite a Co-worker
Send a co-worker an invite to the portal.Just enter their email address and we'll connect them to register. After joining, they will belong to the same company.
You have entered an invalid email address. Please re-enter the email address.
This co-worker has already been invited to the Exchange portal. Please invite another co-worker.
Please enter email address
Send Invite Cancel
Invitation Sent
Your invitation was sent.Thanks for sharing Exchange with your co-worker.
Send New Invite Close
Top Experts
User Count
StefanLundin
Lt. Commander StefanLundin Lt. Commander
23
Benji
Administrator Benji Administrator
9
MortenEnger
Lieutenant JG MortenEnger Lieutenant JG
3
APA
Lieutenant JG APA Lieutenant JG
3
View All

Invite a Colleague

Found this content useful? Share it with a Colleague!

Invite a Colleague Invite
Back to EcoStruxure SEAL Forum
Jim.T
Ensign Jim.T Ensign
Ensign

Posted: ‎2024-12-10 05:09 AM . Last Modified: ‎2024-12-10 05:57 AM

9 Likes
2
710
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-10 05:09 AM . Last Modified: ‎2024-12-10 05:57 AM

SEAL Script: Search and Replace Regular Expressions Quickstart

The search and replace script is a powerful tool and with this update we’re leveling it up even more. However, the tool is only as powerful as its user and therefore this is your chance to level up too!

 

In Search and Replace version 3.4.0 we're introducing Regular Expressions (Regex) as an option when searching. In short Regex is a pattern matching standard that is widely agreed upon and allows you to create powerful patterns that can match text more precisely OR more generally than simple 1:1 matching could ever do.

Writers note: This might seem daunting at first, however, I assure you that any time you spend learning Regex will be paid back ten-fold if your work involves any kind of data manipulation.

 

What does Regex do?

Regex allows you to write patterns instead of words when trying to find whatever it is that you want to replace. For example, trying to replace something short like “P1” => “P2” can be a problem since “P1” will appear in more places than you might expect. Imagine you have 2 folders, what would happen if you replaced “P1” with “P2”:

P1 => P2

P100 => P200

P100 also got renamed despite that not being my intention. Let’s see how Regex can help us in this situation.

 

As mentioned, Regex allows you to write patterns using tokens that match multiple characters according to a set of rules. For example, to solve the issue above we could use the “\b” token to denote that we only want to match “P1” when it is alone. We could write our pattern as: “\bP1\b” and that would result in the following:

P1 => P2

P100 => No Match

Why? Because now we told the Regex engine to search for any “word boundary(\b)” followed by “P1” and then another “word boundary(\b)”. P100 stops matching since the zero that is after “P1” breaks the rules.

 

Exactly what a “word boundary” is would not be the most logical place to start learning Regex, but it is a good example of a simple and applicable case that might come in handy a lot.

 

Resources

https://regex101.com/ – The number 1 tool to both learn and test Regex patterns. Use this while writing your patterns to get live feedback on what matches what and explanations of all available tokens.

 

https://www.youtube.com/watch?v=jCAyQ7C71m4 – This 8-minute video I deemed to be the “best” after searching YouTube for “regex basic usage”.

 

Ask a chatbot – By asking a chatbot to make a regex to match some provided text you will probably get a pattern that is 90% there. Just make sure to read it through and clean up any unnecessary backslashes etc...

 

And finally, this community itself! If you need a regex pattern to save you 4 hours of manual labour but don’t have the time or interest to understand it yourself, post a VERY DETAILED question in the forum and see if another Regex wizard can help you out in designing your pattern. Remember you must provide both what you want to match as well as what you don’t want to match.

 

More tokens

Token

Explanation

\d

Any digit. Ex. 1,2,3,4,5,6,7,8,9,0

\D

Any non-digit. The reverse of the above token

\s

Any whitespace character. Ex. Space, tab, return (newline)

\S

Any non-whitespace character. The reverse of above token

\w

Any word character. Ex. 1,2,3,a,b,c,_ (underscore)

\W

Any non-word character. The reverse of above token

?

Zero or one of the previous character. Ex. ab? Matches “a” and “ab” but not “b”

*

Zero or more of the previous character. Ex. ab* matches “a”, “ab”, “abbb” but not “aab”

+

One or more of the previous character. Ex. ab+ matches “ab”, “abb” but not “a” or “b”

.

Any character. Ex. a. Matches “a” followed by a single character like “ab”, “ac”, “a1”

\b

Word boundary matches the beginning or end of words. Best to test yourself.

 

And many more, please see https://regex101.com/ for more tokens in their “Quick reference” in the bottom right corner. Also try them out in their editor.

 

That’s it for now, and as always, backup your data before performing any Search and Replace action!

Labels
  • Labels:
  • Script
  • Tags:
  • english
  • regex
  • regular expressions
  • seal
Reply

Link copied. Please paste this link to share this article on your social media post.

  • All forum topics
  • Previous Topic
  • Next Topic
Replies 2
Benji
Administrator Benji Administrator
Administrator

Posted: ‎2024-12-10 04:14 PM

0 Likes
0
671
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-10 04:14 PM

Nice and thorough post @Jim.T ! I've used RegEx testing/builder tools in the past (http://www.regex-match-tracer.com being my go-to), but for sure with AI and what other sites offers these days, I myself have to revisit my approach 🙂

Reply

Link copied. Please paste this link to share this article on your social media post.

StefanLundin
Lt. Commander StefanLundin Lt. Commander
Lt. Commander

Posted: ‎2024-12-12 03:07 AM

4 Likes
0
575
  • Mark as New
  • Bookmark
  • Subscribe
  • Mute
  • Subscribe to RSS Feed
  • Permalink
  • Print
  • Email to a Friend
  • Report Inappropriate Content

Link copied. Please paste this link to share this article on your social media post.

Posted: ‎2024-12-12 03:07 AM

 

A typical example where a regex in Search and Replace solves some tricky cases is as follows:

A heating application following Swedish standards contains the following components/identifiers:

  • Pump: P1
  • Expansion vessel: EXP1
  • Pressure Sensor: GP11
  • Second Pump: P12
  • Sourced by another system: VP1 (shown as text in the graphic)

You want to use Search and Replace to change the pump identifier from P1 to P2 without altering any other objects.

StefanLundin_1-1734001566048.png

 


According to the Swedish naming convention, the names of IOs/variables/alarms for a pump named P1 would look like this and are named similarly in TGML and Functionblock programs, and you want the Search and Replace to take care of all of these:

  • VS01-P1
  • P1_STP
  • P1START_FD
  • VS01-P1_D
  • VS01-P1_D_Logg
  • P1_L
  • P1_DTL

To achieve this, you should be able to use the following regex pattern in the Search and Replace script:

(?<![a-zA-Z0-9åäöÅÄÖ])P1(?![0-9])

  • (?<![a-zA-Z0-9åäöÅÄÖ]): This is a negative lookbehind assertion. It ensures that the position before P1 is not preceded by any of the characters in the set [a-zA-Z0-9åäöÅÄÖ]. This set includes:

    • All lowercase and uppercase English letters (a-z, A-Z)
    • Digits (0-9)
    • Swedish characters (å, ä, ö, Å, Ä, Ö)
  • P1: This is the literal string P1 that the pattern is trying to match.

  • (?![0-9]): This is a negative lookahead assertion. It ensures that the position after P1 is not followed by any digit (0-9).

In summary, this regex pattern matches the string P1 only if it is not preceded by any alphanumeric character or Swedish character (å, ä, ö, Å, Ä, Ö) and is not followed by any digit.

Use the pattern like this in the Search & Replace script:
(Ensure you select Regular Expression as the operator)

StefanLundin_0-1734001538771.png

 

 

Reply

Link copied. Please paste this link to share this article on your social media post.

Preview Exit Preview

never-displayed

You must be signed in to add attachments

never-displayed

 
To The Top!

Forums

  • APC UPS Data Center Backup Solutions
  • EcoStruxure IT
  • EcoStruxure Geo SCADA Expert
  • Metering & Power Quality
  • Schneider Electric Wiser

Knowledge Center

Events & webinars

Ideas

Blogs

Get Started

  • Ask the Community
  • Community Guidelines
  • Community User Guide
  • How-To & Best Practice
  • Experts Leaderboard
  • Contact Support
Brand-Logo
Subscribing is a smart move!
You can subscribe to this board after you log in or create your free account.
Forum-Icon

Create your free account or log in to subscribe to the board - and gain access to more than 10,000+ support articles along with insights from experts and peers.

Register today for FREE

Register Now

Already have an account? Login

Terms & Conditions Privacy Notice Change your Cookie Settings © 2025 Schneider Electric

This is a heading

With achievable small steps, users progress and continually feel satisfaction in task accomplishment.

Usetiful Onboarding Checklist remembers the progress of every user, allowing them to take bite-sized journeys and continue where they left.

of