Jump to content

Removing Multiple/Possible Characters From End of Variable


ChrisC123
Go to solution Solved by requinix,

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!

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.