Skip to main content

Timeline for String Pattern to match "x by y"

Current License: CC BY-SA 4.0

9 events
when toggle format what by license comment
Feb 7, 2019 at 8:30 comment added gwr @Jeel name : pattern simply names a pattern you can find it under Pattern in the documentation.
Feb 7, 2019 at 8:27 comment added Jeel Shah This works brilliantly! thank you! Is it correct for me to say that we by doing a: ... we are assigning a, b, c, d to values such as " or 1 or more character and then creating a StringExpression using a ~~ b ~~ c ~~ d? Why is it that quotePatternMod needs to only be mentioned once? Thanks again!
Feb 7, 2019 at 8:25 vote accept Jeel Shah
Feb 7, 2019 at 8:16 history edited gwr CC BY-SA 4.0
corrected error in code
Feb 7, 2019 at 8:06 comment added Jeel Shah It should be "The Machine That Changed the World" by Womack, Jones, and Roos. and only that. I changed the pattern to: Shortest[quotePattern ~~ __ ~~ quotePattern ~~ "by" ~~ ___ ~~ "."] which removes the "And it fails." however, it keeps the preceding string. Is there a way to force that only something which fits that pattern completely is selected? I tried putting "Some surrounding text." in quotes and that was also extracted. StringCases["\"Some surrounding text.\" \"The Machine That Changed \ the World\" by Womack, Jones, and Roos [0]. And it fails.", \ stringPattern]
Feb 7, 2019 at 8:02 comment added gwr @Jeel What should be the string that is extracted in the case you gave? If it were "booktitle by authors" then you might want to go for a period at the end.
Feb 7, 2019 at 7:54 comment added gwr @JeelShah You will have to add Shortest to the pattern otherwise the whole string will match.
Feb 7, 2019 at 7:50 comment added Jeel Shah I have a follow up question, if you don't mind. I'm trying to use StringCases using the pattern you provided to this string "Some surrounding text. \"The Machine That Changed the World\" by \ Womack, Jones, and Roos. And it fails." And it fails to extract the matching string. Am I using something wrong?
Feb 7, 2019 at 7:36 history answered gwr CC BY-SA 4.0