JavaScript SDK: TextTools: text, prices, and numbers
ctx.text() processes values already retrieved. These methods make no network requests.
Each example is a separate fragment inside async function run(ctx). Use await only for methods whose signature returns a Promise.
Methods
clean
ctx.text().clean(value) → string
Remove HTML tags, repeated spaces, and surrounding whitespace.
const result = ctx.text().clean('<b>Product</b>');
money
ctx.text().money(value) → number | null
Turn a price string into a number, accounting for spaces, a comma, and a currency symbol.
const result = ctx.text().money('1 250 RUB');
digits
ctx.text().digits(value) → string
Keep digits only.
const result = ctx.text().digits('SKU 123');
between
ctx.text().between(subject, start, end) → string | null
Take text between the first occurrence of start and the following occurrence of end.
const result = ctx.text().between('Price 1250 RUB', 'Price ', ' RUB');
extract
ctx.text().extract(pattern, subject, group) → string | null
Take one group from the first regular expression match.
const result = ctx.text().extract('(\\d+)', 'Price 1250');