Regular Expression
-
- Posts: 29
- Joined: Fri May 25, 2018
Hello,
i try to use a simple regular Expression, to get some Text into an Array.
I have a Text-Field with the following Content:
And a the following Regular Expression:
/(target="_self">).*?(<\/a>)/g
I tested it on https://www.regexpal.com/ (see Picture). The Regular Expression works well. This code i use in Forms-Designer:
The Result:
match.length == 3 (wrong)
match[0] == target="_self">Text123</a> (correct)
match[1] == target="_self"> (wrong)
match[2] == </a> (wrong)
where am I going wrong???
Best regards
i try to use a simple regular Expression, to get some Text into an Array.
I have a Text-Field with the following Content:
Code: Select all
<a href="" target="_self">Text123</a> some other text <a href="" target="_self">Textyxz</a> and some text i dont want <a href =""> dont want to </a>
/(target="_self">).*?(<\/a>)/g
I tested it on https://www.regexpal.com/ (see Picture). The Regular Expression works well. This code i use in Forms-Designer:
Code: Select all
vartext = $(".csshtmldummy").text();
var patt = new RegExp("(target=\"_self\">).*?(<\/a>)", "g");
var match = patt.exec(vartext);
alert(match.length);
match.length == 3 (wrong)
match[0] == target="_self">Text123</a> (correct)
match[1] == target="_self"> (wrong)
match[2] == </a> (wrong)
where am I going wrong???
Best regards
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Dear slashmaster,
From all of our tests - everything works correctly, it all works. Please, test it from the browser's console as well, it should give you more insight into the errors. Perhaps, the value retrieved from a text field is different, one thing I can think of. If not - send us screenshots with errors.
From all of our tests - everything works correctly, it all works. Please, test it from the browser's console as well, it should give you more insight into the errors. Perhaps, the value retrieved from a text field is different, one thing I can think of. If not - send us screenshots with errors.
Cheers
-
- Posts: 29
- Joined: Fri May 25, 2018
Hi,
i got no Errors... anyway, i solved this Problem with another code:
thank u
i got no Errors... anyway, i solved this Problem with another code:
Code: Select all
vartext = $(".csshtmldummy").text();
var patt = /(target="_self").*?(<\/a>)/g;
var myArray = vartext.match(patt);
console.log(myArray);
Last edited by slashmaster on 07 Aug 2018, edited 1 time in total.
- Nikita Kurguzov
- Posts: 889
- Joined: Mon Jul 03, 2017
Great to hear that! Sorry we couldn't help further, still not sure what could've caused it, but we're glad that the solution you found works! Let us know if you need anything - we'll do our best to help.
Cheers
-
- Information
-
Who is online
Users browsing this forum: No registered users and 26 guests