I've got a contenteditable div and a few paraprahs in it, as the code below.
<!DOCTYPE HTML>
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
</head>
<body>
<div id="main" contenteditable="true" style="border:solid 1px black; width:300px; height:300px"><div>Hello world!</div><div><br></div><div>This is a paragraph</div>
</div>
</body>
</html>
Assuming a situation, I want a code to make a range selection which will contain the string "world! This is" ("world! This is" will get highlighted).
How can I do it? I only need it to work in webkit browsers, specifically Google Chrome.