JavaScript How to use String.match() in javascript string match javascript regular expression,string match javascript boolean,string

I have this code here:

<!DOCTYPE html>
<html>
<body>

<p id="demo">Display the result here.</p> 
<input type = "text" value = "ood" id = "txt1"/>
<script>


var myString = "How much wood could a wood chuck chuck";
var myWord = document.getElementById("txt1").value;   // ood
var myPattern = /.myWord/;        // I want this to be /.ood/
var myResult = myString.match(myPattern);

document.getElementById("demo").innerHTML = myResult;

</script>

</body>
</html>

Now what I want to do here is that I want the value of the txt1 which is ood to be matched in myString.

But putting the variable myWord into the myPattern like this: /.myWord/ won't work. Need help please. Many thanks

UPDATE:

I did everything as what it is in the answers but it returns wood,wood instead of wood only, I just wanted to get only 1 match. Just like using for example /.ood/ - this only returns 1 match. Please help

And also, how can I get the word wood by having only od in my input text. I just wanted this for searching..

Answer:1

I'm implementing a small service for my angularJS app that makes an http request to my server for a couple of text posts. Here's my current implementation: app.factory("postFetcher", ['$http', ...

I'm implementing a small service for my angularJS app that makes an http request to my server for a couple of text posts. Here's my current implementation: app.factory("postFetcher", ['$http', ...

  1. return object from array
  2. return object from arrow function
  3. return object from function javascript
  4. return object from map
  5. return object from promise
  6. return object from async task c#
  7. return object from function powershell
  8. return object from function python
  9. return object from function vba
  10. return object from async function
  11. return object from stream java
  12. return object from class python
  13. return object from list c#
  14. return object from async function javascript
  15. return object from function typescript
  16. return object from function r
  17. return object from arraylist
  18. return object from task c#
  19. return object from web api c#
  20. return object from filter javascript

Is it possible to have the X axis in the middle of the graph? When having Y values both negative and positive - and the X axis is on the 0 value lets say similar to this image

Is it possible to have the X axis in the middle of the graph? When having Y values both negative and positive - and the X axis is on the 0 value lets say similar to this image

I'm migrating a complex map from V2 to V3. The user can digitize polygons and polylines. In V2 getting a high contrast strokeColor was as easy as: var strokeColor = GMap.getCurrentMapType()....

I'm migrating a complex map from V2 to V3. The user can digitize polygons and polylines. In V2 getting a high contrast strokeColor was as easy as: var strokeColor = GMap.getCurrentMapType()....

I have a pop window which contains jQuery from to datepicker. I'm not able to select the End date value. jQuery call $(function() { $("#createdFromDate").datepicker( { defaultDate : "+...

I have a pop window which contains jQuery from to datepicker. I'm not able to select the End date value. jQuery call $(function() { $("#createdFromDate").datepicker( { defaultDate : "+...

  1. jquery datepicker from and to date
  2. jquery datepicker from and to date validation
  3. jquery datepicker from current date
  4. jquery datepicker from to
  5. jquery datepicker from today
  6. jquery datepicker from date to date example
  7. jquery datepicker from to validation
  8. jquery datepicker from to range
  9. jquery datepicker from to example
  10. jquery datepicker from button
  11. jquery datepicker from icon
  12. jquery datepicker with time
  13. jquery datepicker on change
  14. jquery datepicker with month and year selection
  15. jquery datepicker on select
  16. jquery datepicker in angular 4
  17. jquery datepicker in angular 6
  18. jquery datepicker in mvc
  19. jquery datepicker in asp.net
  20. jquery datepicker on select event