Akashii
Akashii

Reputation: 2281

Match 2 character next to each other regex

I'm newbie in regex. I want create a regex for:

Here is something I try to match '--' in first and '$' in last but not work

/^--.*[--](\$)$/g

String I want to pass this regex: --hostname=$HOSTADDRESS$

How can I do that. Please help me

Upvotes: 1

Views: 892

Answers (1)

Ethan
Ethan

Reputation: 4375

/^--.*=\$([^\$]+)\$$/gm

You need to include the m flag after /g to enable multiline ^ and $.

I don't know what you were trying to do with [--], but to match =$ you need to include =\$ in your regex.

Upvotes: 2

Related Questions