-1

How can I find out a string only if it is preceded and followed by specific set of strings?

For example,

<input id="amount" type="hidden" value="105">
<input id="orderId" type="hidden" value="10000">
<input id="userId" type="hidden" value="200">

I want to find out 10000 from the above string. Basically I want to write an expression to find out the value between the below two conditions

  • starting with <input followed by orderId, which is followed by value="

  • ends with ">

.

Raheeb M
  • 385
  • 2
  • 4
  • 11

1 Answers1

1
Regexp: /<input.*orderId.*value="(.*)"/g

Detailed @ https://regex101.com/r/oFuGw4/1

You would not want to use regexp to do this in Javascript.

Just do this

<script>
var value = document.getElementById("orderId").value;
</script>