Effective December 3, NetApp adopts Microsoft’s Business-to-Customer (B2C) identity management to simplify and provide secure access to NetApp resources.
For accounts that did not pre-register (prior to Dec 3), access to your NetApp data may take up to 1 hour as your legacy NSS ID is synchronized to the new B2C identity.
To learn more, read the FAQ and watch the video.
Need assistance? Complete this form and select “Registration Issue” as the Feedback Category.

Active IQ Unified Manager Discussions

RegExp for extracting host names from switch alias

ameegama

Hi

 

I have a  problem with RegExp for extracting host names from  switch alias.

Details:

switchalias : abcdtsm01_aixfcs3  

Hostname :  abcd-tsm01

Expression used: ([a-zA-Z0-9]*)_([^_]+).*    \1           it will capture   " abcdtsm01" which is wrong

How can i add  "-" in the middle  to show as   abcd-tsm01.

 

 

1 ACCEPTED SOLUTION

JGPSHNTAP

Are all the strings the same, meaning four letters and then - or are they different.

 

regex is to pull out what you need, but string manipulation is different

View solution in original post

4 REPLIES 4

ostiguy

Are all the hosts exactly 4letters-xxxxx?

 

Basically, you have an alphanumeric string - how do you know where the dash is supposed to be?

JGPSHNTAP

Are all the strings the same, meaning four letters and then - or are they different.

 

regex is to pull out what you need, but string manipulation is different

View solution in original post

ameegama

Hi

Few Hostnames  same four letters and then  "-" . 

ostiguy

If it is always 4 characters, dash, ...

 

([A-Za-z0-9]{4})([A-Za-z0-9]+)-.*

 

This regular expression will:

Look for exactly 4 alphanumeric case insensitive characters - this will be \1 aka string 1

Look for at least a 2 alphanumeric case insensitive string that follows - this will be \2 aka string 2

Look for a dash, follow by more characters

 

When this pattern matches, you will have 2 strings

 

If you change the format for this rule from "\1" to "\1-\2" , you will build a concatenated string of "string1-string2"

 

I would characterize this regexp as fairly risky - it is only worth trying if ALL of your hosts are named this way.

 

If this pattern only applies for TSM hosts, you will want to write a narrower regexp

Announcements
NetApp on Discord Image

We're on Discord, are you?

Live Chat, Watch Parties, and More!

Explore Banner

Meet Explore, NetApp’s digital sales platform

Engage digitally throughout the sales process, from product discovery to configuration, and handle all your post-purchase needs.

NetApp Insights to Action
I2A Banner
Public