Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <!DOCTYPE html>
<html lang="en">
<head>
	<meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">	
	<link href="https://cdn.jsdelivr.net/npm/[email protected]/dist/css/bootstrap.min.css" rel="stylesheet" integrity="sha384-gH2yIJqKdNHPEq0n4Mqa/HGKIhSkIHeL5AyhkYV8i59U5AR6csBvApHHNl/vI1Bx" crossorigin="anonymous">
	<link rel="stylesheet" href="js_style.css" />
	<script src="https://cdn.jsdelivr.net/npm/[email protected]/dist/js/bootstrap.bundle.min.js" integrity="sha384-A3rJD856KowSb7dwlZdYEkO39Gagi7vIsF0jrRAoQmDKKtQBHUuLZ9AsSv4jD4Xa" crossorigin="anonymous"></script>
	<script src="lesson34.js"></script>
</head>
<body>
	<div id="less34">
		<div class="container">
			<div class="row">
				<div class="col-lg-12">
					<h2>Поиск слова используя регулярное выражение</h2>
					<textarea id="text_34" cols="35" rows="5">Ехал Грека через реку, видит Грека в реке рак, сунул Грека руку в реку, рак за руку Греку цап.</textarea><br>
					<input type="text" id="word_34" placeholder="Введите слово"><br><br>
					<input type="button" id="btn_34" value="Найти слово" onclick="FindWord()"><br><br>
					<h4 id="output_34"></h4>
				</div>
			</div>
		</div>
	</div>
</body>
</html>

              
            
!

CSS

              
                #less34{
  margin-top: 40px;
  margin-bottom: 40px;
}
#less34 h2{
  margin-bottom: 25px;
}
span{
  color:red;
}
              
            
!

JS

              
                function FindWord() {
    var gText = document.getElementById('text_34').value;
    var gWord = document.getElementById('word_34').value;
    var gOutput = document.getElementById('output_34');


    var reg = new RegExp(gWord , 'gi');
    var newWord = gText.match(reg);
    
    
    var replaceText = gText.replaceAll(newWord, `<span>${newWord}</span>`);
    gOutput.innerHTML = replaceText;

}

              
            
!
999px

Console