Jump to content

Removing Multiple/Possible Characters From End of Variable


ChrisC123

Recommended Posts

I hate asking for help (some searches usually find the answer), but I can't figure this one out....

 

 

I need to strip a handful of possible characters off the end of a variable and have been playing with trim, str_replace and preg_replace with no luck. I can get them to work fine with a specific name/characters but not one that covers all possible options.

 

Our employees desktop and laptops use a standard naming convention that could have multiple characters at the end of their device name which is based on their name. I am trying to strip off all characters to just get the employee name.

 

Here are some examples of our devices name:

JDOE

JDOE_L

JDOE-L

JDOE-L2 (or any numeric range such as 2-9)

JDOE2 (or any numeric range such as 2-9)

 

I am trying to get only the JDOE from the device name.

 

 

Any help would be great. Thanks!

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.