ScottC
ScottC

Reputation: 462

reg expression search and replace error

I am trying to search a string which is the list of groups a user belongs to in unix,

and replace the group vsifax or is its a middle or end of the string group the , before it with a null value or space whichever is easier

$gs =~ s/*,vsifax//;

but this returns an error when I try to run the script

$ usermove.pl > users.sh
Quantifier follows nothing in regex; marked by <-- HERE in m/* <-- HERE ,vsifax/
at usermove.pl line 13.

I can't see what the issue would be I have read and re read over a few tutorials on regular expressions and its killing me

Upvotes: 0

Views: 630

Answers (2)

ap0calypse
ap0calypse

Reputation: 86

I guess this command should look like this to work.

$gs =~ s/*,vsifax//;

should be:

$gs =~ s/,?vsifax//;

I guess you want to delete the group name and the last comma, right?

Upvotes: 4

Fred
Fred

Reputation: 5006

Try this, I don't think * is needed in your regex

$gs =~ s/(,?vsifax)|(vsifax,?)//;

Upvotes: 2

Related Questions