ydoow
ydoow

Reputation: 2996

regex to remove dash between alphanumeric

I am looking for a regex to remove dash between alphanumeric. Any leading or tailing dash should not be removed.

For example, abc-edd would result in abcedd.

I tried

Regex.Replace(json, @"^\w-^\w", "");

However it is not doing anything.

Upvotes: 0

Views: 983

Answers (1)

Alexander Petrov
Alexander Petrov

Reputation: 14231

Try this pattern:

@"(?<=\w)-(?=\w)"

Upvotes: 3

Related Questions