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

Find the position of a string element, knowing only part of the string

$
0
0

I have a list, e.g.:

list = {1, 2, 3, "Element 1", 4, 5, "Element 2", "Something else 1", "etcetera"}

Now, I want all elements starting with "El". Using Position, I could find the position of e.g. "Element 1":

Position[list, "Element 1"]

But, I would like to know the positions of "Element 1" and "Element 2", as both start with "El". So, I would like to have something like

Position[list, "El"_]

I just can't get something like this to work.

Thanks for any help.


Viewing all articles
Browse latest Browse all 186

Trending Articles



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