I would do it this way because i'm lazy:
 -replace " ?\(.*?\) ?"

PS > "(ywfew) Jessica (Yvs)" -replace " ?\(.*?\) ?"
Jessica
PS > "(ywfew)Jessica (Yvs)" -replace " ?\(.*?\) ?"
Jessica
PS > "Jessica (Yvs)" -replace " ?\(.*?\) ?"
Jessica

Thanks,

Devin Rich
Systems Administrator


On Wed, Nov 30, 2016 at 2:00 PM, Orlebeck, Geoffrey <
geoffrey.orleb...@montagehealth.org> wrote:

> I’m working on a script that gets some data fed into it. Some of the
> fields have two names, one wrapped in (). Example: “Jessica (Yvonne)”. I am
> trying to remove everything within the (), but I’m not sure how. I’ve tried
> several regex expressions, and I’m able to remove the (), but not the
> content within them. Essentially I’d like to turn “Jessica (Yvonne)” into
> “Jessica” (even if there is whitespace after ‘Jessica’).
>
>
>
> I tried several suggestions I saw online, escaping the “(“ and “)”, or
> using $regex = [regex]::Escape('()'), but I’m not sure how to basically
> say “Find ‘(‘ and remove everything until ‘)’ [including the parenthesis].
>
>
>
> Any helpful tips or links where people are doing this? I tried doing array
> matches, removing the () and then selecting only the first position, but
> then discovered some of the fields have the parenthesis first (e.g.
> “(Yvonne) Jessica”.
>
>
>
> Thanks for any suggestions.
>
>
> Confidentiality Notice: This is a transmission from Community Hospital of
> the Monterey Peninsula. This message and any attached documents may be
> confidential and contain information protected by state and federal medical
> privacy statutes. They are intended only for the use of the addressee. If
> you are not the intended recipient, any disclosure, copying, or
> distribution of this information is strictly prohibited. If you received
> this transmission in error, please accept our apologies and notify the
> sender. Thank you.
>
>

-- 
The information contained in this message is privileged, confidential, and 
protected from disclosure. If you are not the intended recipient, you are 
hereby notified that any review, printing, dissemination, distribution, 
copying or other use of this communication is strictly prohibited. If you 
have received this communication in error, please notify us immediately by 
replying to the message and deleting it from your computer.



Reply via email to