- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 01:49 PM
I have a string of "<title>This is a string</title>" and I need to set the values between the tags as a variable thus returning "This is a string" (without quotes of course)...
I tried this but it does not work...
var str = "<title>This is a string</title>";
var mySubString = str.substring(str.indexOf("<title>") +1, str.indexOf("</title>"));
gs.print(mySubString);
Am i going to have to Regex to get this value ?
Solved! Go to Solution.
- Labels:
-
User Experience and Design
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 02:14 PM
Ah... got it:
var inText = current.variables.body_html;
var regex = /(?:\<title>)(.*)(?:\<)/g;
inText = regex.exec(inText);
var rslt = inText[1];
current.description = rslt;
current.short_description = rslt;
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 02:14 PM
Ah... got it:
var inText = current.variables.body_html;
var regex = /(?:\<title>)(.*)(?:\<)/g;
inText = regex.exec(inText);
var rslt = inText[1];
current.description = rslt;
current.short_description = rslt;

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎08-20-2022 02:22 PM
How do you accomplish this is Flow Designer using the transform function regex?

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎02-22-2022 02:17 PM
Generally speaking - yes.
This is a little trick that works to strip out html tags without having to hard-code them individually.
var str = "<title>This is a string</title>";
var mySubString = str.replace(/(<([^>]+)>)/gi, "");
gs.print(mySubString);
I hope this helps!
If this was helpful, or correct, please be kind and mark the answer appropriately.
Michael Jones - Proud member of the GlideFast Consulting Team!
Michael D. Jones
Proud member of the GlideFast Consulting Team!