Regex for Machine Name

Beth_S
Tera Contributor

I am looking for a Regex to use for machine or computer names.  Does anyone have one that works?

1 ACCEPTED SOLUTION

Amit Pandey
Kilo Sage

Hi @Beth_S 

 

I had similar requirement and I got away with-

 

/\b[a-zA-Z0-9_-]+\b/g

 

Please mark my answer helpful and correct.

 

Regards,

Amit

View solution in original post

2 REPLIES 2

SK Chand Basha
Giga Sage

Hi @Beth_S 

 

However, a common pattern that often works for machine or computer names typically includes alphanumeric characters, hyphens, and underscores.

 

^[a-zA-Z0-9_-]+$

 

https://regex101.com/

 

Use above link for testing 

 

Mark it Helpful and Accept Solution!! If this helps you to understand

Amit Pandey
Kilo Sage

Hi @Beth_S 

 

I had similar requirement and I got away with-

 

/\b[a-zA-Z0-9_-]+\b/g

 

Please mark my answer helpful and correct.

 

Regards,

Amit