-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathregex.html
More file actions
116 lines (110 loc) · 3.5 KB
/
regex.html
File metadata and controls
116 lines (110 loc) · 3.5 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>text replacer</title>
<style>
body {
background-color: lightblue;
margin: 10vh;
}
b{
font-size: 20px;
font-family: Arial, Helvetica, sans-serif;
}
p{
border-style: solid;
border-width: 3px;
border-color: silver;
background-color: lightcyan;
padding: 10px;
border-radius: 4px;
width: 80vw;
}
pre{
margin: 0
}
button{
font-size:16px;
margin:10px;
height:30px;
width:100px;
border-radius: 4px;
color: white;
background:navy;
cursor: pointer;
border: none
}
button:hover{
background-color: blue;
}
textarea{
font-size:16px;
overflow: auto;
resize: vertical;
height: 300px;
width: 80vw;
max-height: 700px;
min-height: 200px;
border-radius: 4px;
padding: 10px;
}
#regexInput, #regexOutput{
font-size:16px;
height: 30px;
width: 80vw
}
.checkbox-container {
display: flex;
align-items: center;
margin-bottom: 10px;
}
.checkbox-container label {
margin-left: 10px;
font-size: 16px;
}
span{
background-color: yellow;
}
</style>
</head>
<body>
<header><h1>Text Replacer</h1></header>
<textarea id="text" rows = "5" placeholder="enter text to be replaced" onchange="browser_replace()"></textarea><br>
<input id="regexInput" value='\"(.+)\"' onchange="browser_replace()"><br>
<input id="regexOutput" value="='$1'!A1:T99" onchange="browser_replace()"><br>
<button onclick = 'browser_replace()' id = 'btn1' >replace</button>
<div class="checkbox-container">
<input type="checkbox" id="case" onchange="browser_replace()">
<label for="case">Case Insensitive</label>
</div>
<div class = 'container'>
<div>
<p>
<button id="copy" onclick="copy()">copy</button>
<b id="output"></b>
</p>
</div>
</div>
<script type="text/javascript">
function browser_replace(){
var flag = document.getElementById("case").checked ? 'gi' : 'g';
var text = document.getElementById("text").value;
var regexInput = document.getElementById("regexInput").value;
var regexOutput = document.getElementById("regexOutput").value;
document.getElementById("output").innerHTML = "<pre>" + text.replace(new RegExp(regexInput, flag),`<span>${regexOutput}</span>`) + "</pre>";
}
function copy(){
var text = document.getElementById("output").innerText;
navigator.clipboard.writeText(text).then(() => {
alert("copied to clipboard!")});
}
document.getElementById('text').value = `"C:\\folder\\file.xlsx"`;
browser_replace();
document.getElementById('text').focus();
document.getElementById('tsvB').select();
</script>
</body>
</html>