Skip to main content

How to retrieve value between 2 characters?

Extract

var Textstr="Cart Betweensaved Delimitersas inQuote ScenarioNo Editor:14393430*";

Usevar delimiter-basedmySubString extraction= whenstr.substring(str.lastIndexOf(":") + 1,str.lastIndexOf("*"));

You can use the below code to retrieve the value needed by a test appears between two stable characters or strings.

  • Confirm the start":" and end"*" delimiters are
    stable across environments.
  • Handle missing or repeated delimiters predictably.
  • Trim only whitespace that is not part of the expected value.
  • Avoid delimiter extraction when a structured field or locator is available.

Validation workflow

  1. Capture the source text.
  2. Identify the start and end delimiters.
  3. Extract and normalize the value.
  4. Validate the extracted value or store it for later steps.

Last updated: SeptemberJune 20,26, 20262023

If you have any feedback on this topic, please contact us at documentation@appvance.ai