Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
BedrockMission!

Learn More

View all

Sign in to view all badges

Select text between two symbols

Avatar

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile

Avatar
Validate 1
Level 1
awmackenzie
Level 1

Likes

2 likes

Total Posts

14 posts

Correct Reply

1 solution
Top badges earned
Validate 1
Boost 1
Affirm 1
View profile
awmackenzie
Level 1

01-06-2018

I have a table that gets populated with different strings of text. Sometimes there will be lines of text that are surrounded by a "|" (pipe) symbol within them.

For example, This | is a example | line of text

I currently have some coding that will remove the pipe symbols from the text,

DATA: i_TABLE LIKE TABLE.
LOOP AT TABLE INTO i_TABLE.
REPLACE ALL OCCURRENCES OF '|'  IN i_TABLE-FIELD1
      WITH ''.
MODIFY TABLE FROM i_TABLE.

RESULT: This is a example line of text

What I need to do now is make an exception for a certain category that will only select the text from within the pipes (and remove the pipes)

DESIRED RESULT: is a example

I am not sure how to structure that code. can anyone give me some suggestions?

Best Regards,

Andrew

Accepted Solutions (1)

Accepted Solutions (1)

Avatar

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile

Avatar
Boost 50
MVP
_Bruce_Robertson
MVP

Likes

269 likes

Total Posts

1,782 posts

Correct Reply

372 solutions
Top badges earned
Boost 50
Boost 5
Boost 3
Boost 250
Boost 25
View profile
_Bruce_Robertson
MVP

02-06-2018

Hi Andrew,

You can use the split method to break the string into an array and then grab the second occurrence.

var textArray = "This | is a example | line of text".split("|");

var secondText = textArray[1];

If you need the remove the leading and trailing spaces, and all your users have Reader DC then you can use;

seondText.trim()

Regards

Bruce

Answers (0)