Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Viewing all articles
Browse latest Browse all 188

Extract strings containing digit characters with StringCases

$
0
0

I have a large string like this:

string = {"text, 1998, TEXTDATA, text, 2007, NEXTTEXTDATA"};

Now I want to extract TEXTDATA and NEXTTEXTDATA. I tried to use StringCases and Shortestin combination with DigitCharacterlike this:

StringCases[string, Shortest[DigitCharacter .. ~~ ___ ~~ ", "]]

but this of course yields only

(* {{"1998, ", "2007, "}} *)

So either there is a way to combine DigitCharacterwith the FIRST comma (and then probably Shortestwould work) or there is a way without Shortest?


Viewing all articles
Browse latest Browse all 188

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>