Extract exact text in tags
up vote
0
down vote
favorite
I want to be able to extract the text embedded between a tag e.g. I want to get the text "TEST" from
"<"Subject">" TEST "</"Subject">"
I have used First
RegexMatch /(<Subect>).*(</Subject>)/i)
but get an error
"/ An unescaped delimiter must be escaped with a backslash ()".
Any help on how I can achieve this?
javascript
add a comment |
up vote
0
down vote
favorite
I want to be able to extract the text embedded between a tag e.g. I want to get the text "TEST" from
"<"Subject">" TEST "</"Subject">"
I have used First
RegexMatch /(<Subect>).*(</Subject>)/i)
but get an error
"/ An unescaped delimiter must be escaped with a backslash ()".
Any help on how I can achieve this?
javascript
2
I may be missing something, but can't you simply useinnerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
– DBS
Nov 8 at 16:55
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00
add a comment |
up vote
0
down vote
favorite
up vote
0
down vote
favorite
I want to be able to extract the text embedded between a tag e.g. I want to get the text "TEST" from
"<"Subject">" TEST "</"Subject">"
I have used First
RegexMatch /(<Subect>).*(</Subject>)/i)
but get an error
"/ An unescaped delimiter must be escaped with a backslash ()".
Any help on how I can achieve this?
javascript
I want to be able to extract the text embedded between a tag e.g. I want to get the text "TEST" from
"<"Subject">" TEST "</"Subject">"
I have used First
RegexMatch /(<Subect>).*(</Subject>)/i)
but get an error
"/ An unescaped delimiter must be escaped with a backslash ()".
Any help on how I can achieve this?
javascript
javascript
edited Nov 8 at 16:59
Lelio Faieta
4,02552345
4,02552345
asked Nov 8 at 16:46
Paul
142
142
2
I may be missing something, but can't you simply useinnerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
– DBS
Nov 8 at 16:55
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00
add a comment |
2
I may be missing something, but can't you simply useinnerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML
– DBS
Nov 8 at 16:55
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00
2
2
I may be missing something, but can't you simply use
innerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML– DBS
Nov 8 at 16:55
I may be missing something, but can't you simply use
innerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML– DBS
Nov 8 at 16:55
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00
add a comment |
1 Answer
1
active
oldest
votes
up vote
0
down vote
If you want to do this with a regex, you have to escape '/' (with a preceding '') if it's part of your search string
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
add a comment |
1 Answer
1
active
oldest
votes
1 Answer
1
active
oldest
votes
active
oldest
votes
active
oldest
votes
up vote
0
down vote
If you want to do this with a regex, you have to escape '/' (with a preceding '') if it's part of your search string
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
add a comment |
up vote
0
down vote
If you want to do this with a regex, you have to escape '/' (with a preceding '') if it's part of your search string
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
add a comment |
up vote
0
down vote
up vote
0
down vote
If you want to do this with a regex, you have to escape '/' (with a preceding '') if it's part of your search string
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
If you want to do this with a regex, you have to escape '/' (with a preceding '') if it's part of your search string
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
s = '"<"Subject">" TEST "</"Subject">"';
console.log(s.replace(/"<"Subject">"(.*)"</"Subject">"/, '$1'))
edited Nov 8 at 16:56
answered Nov 8 at 16:51
Jim B.
2,026727
2,026727
add a comment |
add a comment |
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
StackExchange.ready(
function () {
StackExchange.openid.initPostLogin('.new-post-login', 'https%3a%2f%2fstackoverflow.com%2fquestions%2f53212388%2fextract-exact-text-in-tags%23new-answer', 'question_page');
}
);
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Sign up or log in
StackExchange.ready(function () {
StackExchange.helpers.onClickDraftSave('#login-link');
});
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Sign up using Google
Sign up using Facebook
Sign up using Email and Password
Post as a guest
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
Required, but never shown
2
I may be missing something, but can't you simply use
innerHTML
? developer.mozilla.org/en-US/docs/Web/API/Element/innerHTML– DBS
Nov 8 at 16:55
isn't your error self explaining?
– Lelio Faieta
Nov 8 at 17:00