Delete String After Certain Character

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Delete String After Certain Character

Post by CElwell » Sun May 08, 2016 6:28 am

Is there a way to delete the string of text after a specific character?

For example my data is this:
(Words here) But I don't want the words here

I want my data to look like this:
Words here

I want to display just the words within the parenthesis. I deleted the first character, but no matter if I try using delete, replace, etc I can't get rid of the rest. Is this possible?

Thank you,
Cassidy

dunbarx
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 10305
Joined: Wed May 06, 2009 2:28 pm

Re: Delete String After Certain Character

Post by dunbarx » Sun May 08, 2016 7:31 am

Hi.

Easy. Look up the "offset" function. You would (Pseudo)

Code: Select all

put your Text into a variable
get the offset of the char you want to delimit that text
delete all the chars after the offset value
 
Another way (pseudo)

Code: Select all

set the item delimiter to the char of interest
delete item 2 of your text
Craig Newman

CElwell
Posts: 38
Joined: Thu Feb 04, 2016 6:29 pm

Re: Delete String After Certain Character

Post by CElwell » Sun May 08, 2016 6:59 pm

Thank you so much I got it to work with offset :)

Code: Select all

delete char 1 of test
put offset(")", test) into tOffset
delete char tOffset in test
delete char (tOffset + 1) to -1 of test

Post Reply