cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
%3CLINGO-SUB%20id%3D%22lingo-sub-723579%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%ED%85%8D%EC%8A%A4%ED%8A%B8%EC%97%90%EC%84%9C%20%EC%88%AB%EC%9E%90%EA%B0%80%20%ED%8F%AC%ED%95%A8%EB%90%9C%20%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%84%20%EC%A0%9C%EA%B1%B0%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723579%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%EC%95%88%EB%85%95%2C%3CBR%20%2F%3E%20JSL%EC%9D%84%20%EC%82%AC%EC%9A%A9%ED%95%98%EC%97%AC%20%EC%88%AB%EC%9E%90%EA%B0%80%20%ED%8F%AC%ED%95%A8%EB%90%9C%20%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%84%20%EC%A0%9C%EA%B1%B0%ED%95%98%EB%8A%94%20%EB%B0%A9%EB%B2%95%EC%9D%B8%EA%B0%80%EC%9A%94%3F%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%EC%98%88%3A%3CBR%20%2F%3E%20%EC%82%AC%EA%B3%BC%20%3CSTRONG%3E4%3C%2FSTRONG%3E%20%EA%B0%9C%EC%99%80%20%EB%B0%94%EB%82%98%EB%82%98%20%3CSTRONG%3E2%EA%B0%9C%3C%2FSTRONG%3E%20%EB%A5%BC%20%EB%A8%B9%EC%97%88%EC%8A%B5%EB%8B%88%EB%8B%A4%3CBR%20%2F%3E%20%EB%AA%A8%EB%8D%B8%20%EB%B2%88%ED%98%B8%EB%8A%94%20%3CSTRONG%3E0998GBELS%3C%2FSTRONG%3E%20%EC%9E%85%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%3CSTRONG%3E03%2F45%3C%2FSTRONG%3E%20%EB%8A%94%20%ED%99%95%EC%9D%B8%ED%95%A0%20%EB%B9%84%EC%9C%A8%EC%9E%85%EB%8B%88%EB%8B%A4.%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3CP%3E%ED%83%80%EA%B2%9F%20%EC%B6%9C%EB%A0%A5%3A%3C%2FP%3E%3CP%3E%EB%82%98%EB%8A%94%20%EC%82%AC%EA%B3%BC%EC%99%80%20%EB%B0%94%EB%82%98%EB%82%98%EB%A5%BC%20%EB%A8%B9%EC%97%88%EB%8B%A4%3CBR%20%2F%3E%20%EB%AA%A8%EB%8D%B8%20%EB%B2%88%ED%98%B8%EB%8A%94%3C%2FP%3E%3CP%3E%3CSTRONG%3E%20%3C%2FSTRONG%3E%ED%99%95%EC%9D%B8%ED%95%B4%EC%95%BC%20%ED%95%A0%20%EB%B9%84%EC%9C%A8%EC%9E%85%EB%8B%88%EB%8B%A4%3C%2FP%3E%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E%3CLINGO-LABS%20id%3D%22lingo-labs-723579%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CLINGO-LABEL%3E%EC%9E%90%EB%8F%99%ED%99%94%20%EB%B0%8F%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8C%85%3C%2FLINGO-LABEL%3E%3C%2FLINGO-LABS%3E%3CLINGO-SUB%20id%3D%22lingo-sub-723591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3ERe%3A%20%ED%85%8D%EC%8A%A4%ED%8A%B8%EC%97%90%EC%84%9C%20%EC%88%AB%EC%9E%90%EA%B0%80%20%ED%8F%AC%ED%95%A8%EB%90%9C%20%EB%AC%B8%EC%9E%90%EC%97%B4%EC%9D%84%20%EC%A0%9C%EA%B1%B0%ED%95%A9%EB%8B%88%EB%8B%A4.%3C%2FLINGO-SUB%3E%3CLINGO-BODY%20id%3D%22lingo-body-723591%22%20slang%3D%22en-US%22%20mode%3D%22CREATE%22%3E%3CP%3E%EC%9D%B4%EA%B2%83%EC%9D%80%20%EC%9E%91%EB%8F%99%ED%95%98%EC%A7%80%EB%A7%8C%20%EC%A0%95%EA%B7%9C%20%ED%91%9C%ED%98%84%EC%8B%9D%EC%97%90%20%EC%9D%B5%EC%88%99%ED%95%9C%20%EC%82%AC%EB%9E%8C%EC%9D%80%20%EC%8A%A4%ED%81%AC%EB%A6%BD%ED%8A%B8%EB%A5%BC%20%EB%8B%A8%EC%88%9C%ED%99%94%ED%95%A0%20%EC%88%98%20%EC%9E%88%EC%8A%B5%EB%8B%88%EB%8B%A4.%3C%2FP%3E%0A%3CPRE%3E%3CCODE%20class%3D%22%20language-jsl%22%3ENames%20Default%20To%20Here(%201%20)%3B%0AtheString%20%3D%20%22I%20ate%204%20apples%20and%202%20bananas%0Athe%20model%20number%20is%200998GBELS%0A%0A03%2F45%20is%20the%20ratio%20to%20check%22%3B%0A%0AtheList%20%3D%20Words(%20theString%2C%20%22%20%5C!n%5C!r%5C!t%22%20)%3B%0AadjustedString%20%3D%20%22%22%3B%0AFor%20Each(%20%7Bmember%7D%2C%20theList%2C%0A%09Show(%20member%20)%3B%0A%2F%2Fmember%3Dthelist%5B1%5D%0A%09found%20%3D%20%22No%22%3B%0A%09If(%20!Contains(%20member%2C%20%220%22%20)%2C%0A%09%09If(%20!Contains(%20member%2C%20%221%22%20)%2C%0A%09%09%09If(%20!Contains(%20member%2C%20%222%22%20)%2C%0A%09%09%09%09If(%20!Contains(%20member%2C%20%223%22%20)%2C%0A%09%09%09%09%09If(%20!Contains(%20member%2C%20%224%22%20)%2C%0A%09%09%09%09%09%09If(%20!Contains(%20member%2C%20%225%22%20)%2C%0A%09%09%09%09%09%09%09If(%20!Contains(%20member%2C%20%226%22%20)%2C%0A%09%09%09%09%09%09%09%09If(%20!Contains(%20member%2C%20%227%22%20)%2C%0A%09%09%09%09%09%09%09%09%09If(%20!Contains(%20member%2C%20%228%22%20)%2C%0A%09%09%09%09%09%09%09%09%09%09If(%20!Contains(%20member%2C%20%229%22%20)%2C%0A%09%09%09%09%09%09%09%09%09%09%09adjustedString%20%3D%20Trim(%20adjustedString%20%7C%7C%20%22%20%22%20%7C%7C%20member%20)%0A%09%09%09%09%09%09%09%09%09%09)%0A%09%09%09%09%09%09%09%09%09)%0A%09%09%09%09%09%09%09%09)%0A%09%09%09%09%09%09%09)%0A%09%09%09%09%09%09)%0A%09%09%09%09%09)%0A%09%09%09%09)%0A%09%09%09)%0A%09%09)%0A%09)%3B%0A)%3B%0A%0AShow(%20adjusted%20String%20)%3B%3C%2FCODE%3E%3C%2FPRE%3E%0A%3CP%3E%20%3C%2FP%3E%3C%2FLINGO-BODY%3E
Choose Language Hide Translation Bar
dadawasozo
Level IV

remove string that contains number from text

Hi,
 is that a way to remove any string that contain numbers using JSL?

 

Example:
I ate 4 apples and 2 bananas
the model number is 0998GBELS

03/45 is the ratio to check

 

Targeted Output:

I ate apples and bananas
the model number is 

 is the ratio to check

 

3 REPLIES 3
txnelson
Super User

Re: remove string that contains number from text

This works, but someone familiar with Regular Expressions would be able to simplify the script

Names Default To Here( 1 );
theString = "I ate 4 apples and 2 bananas
the model number is 0998GBELS

03/45 is the ratio to check";

theList = Words( theString, " \!n\!r\!t" );
adjustedString = "";
For Each( {member}, theList,
	Show( member );
//member=thelist[1]
	found = "No";
	If( !Contains( member, "0" ),
		If( !Contains( member, "1" ),
			If( !Contains( member, "2" ),
				If( !Contains( member, "3" ),
					If( !Contains( member, "4" ),
						If( !Contains( member, "5" ),
							If( !Contains( member, "6" ),
								If( !Contains( member, "7" ),
									If( !Contains( member, "8" ),
										If( !Contains( member, "9" ),
											adjustedString = Trim( adjustedString || " " || member )
										)
									)
								)
							)
						)
					)
				)
			)
		)
	);
);

Show( adjusted String );

 

Jim
dadawasozo
Level IV

Re: remove string that contains number from text

I have many lines to process (in hundred millions), doing so will cause higher latency. I wonder if there is a better way to remove those strings that contain number with lower latency ?

 

jthi
Super User

Re: remove string that contains number from text

Not sure i this would work in all situations but it does for these examples

Names Default To Here(1);

strs = {
"I ate 4 apples and 2 bananas",
"the model number is 0998GBELS",
"03/45 is the ratio to check"
};

result2 = Transform Each({str}, strs,
	Regex(str, "\w*\S*\d+\w*\S*", "", GLOBALREPLACE)
);

show(result2); // result2 = {"I ate apples and bananas", "the model number is ", " is the ratio to check"};

Edit:

I think that regex can be simplified a bit to

Regex(str, "\S*\d+\S*", "", GLOBALREPLACE)

https://regex101.com/r/PM4UQn/1 

-Jarmo