Timeline for An equivalent to Condition that I can use anonymously when string pattern matching
Current License: CC BY-SA 3.0
4 events
when toggle format | what | by | license | comment | |
---|---|---|---|---|---|
Jul 26, 2015 at 18:51 | comment | added | Philip Maymin |
Programmatically you could substitute in Unique : StringMatchQ[#, StringExpression @@ With[{each = p__ /; endsWithSpaceQ@p}, Table[each /. p -> Unique[], {2}]] ~~ "17"] & /@ {str1, str2}
|
|
Jul 26, 2015 at 15:47 | comment | added | Mr.Wizard |
@hYPotenuser Believe me I understand your frustration; this (to the best of my knowledge) is one of those peculiar missing pieces you think should be there but isn't. If you give a more representative example I might be able to give another recommendation. Also consider the number of forms that have to be tried; it may be better to abandon pattern matching and parse the string yourself, e.g. StringSplit or whatever, then work from there.
|
|
Jul 26, 2015 at 15:41 | comment | added | hYPotenuser | Unlike in my toy example, the real pattern I'm trying to match repeats an arbitrary number of times, making the prospect of generating patterns programmatically a little scarier. I'll play with it a bit, but seeing that a Wizard doesn't know a general solution to what seems to be a pretty elementary problem suggests that one might not exist and I should start thinking about hacking around the specific case. | |
Jul 26, 2015 at 15:15 | history | answered | Mr.Wizard | CC BY-SA 3.0 |