17

StringMatchQ["aabbc", "*a*c*"] True StringMatchQ["aabbc", "*b*a*"] False You can also use LongestCommonSequence to construct a function ClearAll[strngCntnsQ] strngCntnsQ = LongestCommonSequence[##] == #2 &; strngCntnsQ["aabbc", "ac"] True strngCntnsQ["aabbc", "ba"] False


17

When you use the "Base64" you are encoding a particular file format. For Export calls the file format is inferred from the file name given, like Export["file.ext.b64", expr] uses the ext format. When used with ExportString, the format is chosen automatically. You can see here that the automatically chosen format is "String": ExportString["foobar中文", {"...


14

Is this what you need? StringContainsQ["aabbc","a" ~~ ___ ~~ "c"] True The following documentation pages should help you get going with string patterns in Wolfram Language: https://reference.wolfram.com/language/tutorial/StringPatterns.html https://reference.wolfram.com/language/tutorial/WorkingWithStringPatternsOverview.html edit Here is a function ...


12

The language has StringContainsQ and ContainsAll, it seems we need a combination of the two: StringContainsAll[string_String, patts_List, opts : OptionsPattern[]] := AllTrue[patts, StringContainsQ[string, #, opts] &]; StringContainsAll[patts_List, opts : OptionsPattern[]][x_] := StringContainsAll[x, patts, opts] Now you can get the word list ...


11

The notebook interface and the kernel have different parsers, because the notebook needs to manipulate the input before the kernel sees it for a variety of reasons. There are many differences between the two parsers. It has not been a priority to Wolfram to fix the differences. I have been trying to catalog the differences here (rendered as a webpage here)....


11

Short Version Order matters when specifying replacement rules. Rules are tried from left-to-right. Each rule will attempt to match and replace as much of the string as possible before moving on to the next rule. Patterns like ___ are very broad and will match anything. More narrowly focused patterns might be more applicable (e.g. Whitespace or Except[...


10

StringSplit[#, WhitespaceCharacter... ~~ n : NumberString :> n] & /@ lis {{{"a (b)", "1"}, {"c", "2"}}, {{"d", "3"}, {"e f", "4"}}}


10

WReach covered this well, but in supplement consider using the third parameter of StringReplace to see how a replacement evolves: $patterns = Sequence["e" -> ".", "t" -> "-"]; StringReplace[ "eeeeee ttt ee", {$patterns, __ ~~ "ttt" ~~ _ :> "abc"}, # ] & ~Array~ 10 // Column .eeeee ttt ee ..eeee ttt ee ...eee ttt ee ....ee ttt ee .....e ...


10

featureList = {"ML #", "Property Type", "SubSpcSqFt", "Land Sz SF", "Building Type", "List Date", "Yr Blt", "Address", "Area", "Class", "Clear Ceiling Ht (Feet)", "Lot Frontage (ft)", "Lot Depth (ft)", "Zone", "Price", "Sale Type", "Transaction Type", "Zoning/Land Use", "Amenities-HVAC System", "Building Type-Freestanding", "HVAC-See ...


10

lst = {"Today+100", "Yesterday-200"}; StringSplit StringSplit[lst, RegularExpression["([+-]\\d+)"] :> ToExpression@"$1"] {{"Today", 100}, {"Yesterday", -200}} StringSplit[lst, n : NumberString :> ToExpression@n] {{"Today", 100}, {"Yesterday", -200}} StringReplace List @@@ StringReplace[lst, RegularExpression["([+-]\\d+)"] :> ToExpression@"...


10

Please also see a related problem here, it might give you more ideas. Words can be banal wrt all words in the dictionary or wrt some particular list of words. Let's consider the later case. WordFrequencyData gives the frequency of word in typical published English text. Within a given list of words you can find the max-frequency word and rescale the rest of ...


9

Some options: Pick[ lis, StringStartsQ[lis[[All, 1]], "a"] ] {{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}} Select[lis, StringStartsQ[First[#], "a"] &] {{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}} Cases[lis, {_?(StringStartsQ["a"]), ___}] {{"ab", 2, "c", 3}, {"ac", 5, "f", 6}, {"ad", 9, "c", 10}}


9

StringReplace["CompactSubspaceOfHausdorffSpaceIsClosed", u_?UpperCaseQ :> " " <> ToLowerCase[u]] (*" compact subspace of hausdorff space is closed"*)


9

AlphabeticOrder can compare strings alphabetically (or by other conventions used in dictionaries by various languages).


8

I suspect, much to my chagrin, that the FE is right and the InputForm parser is wrong. For one thing, the kernel itself thinks that parens are needed for Repeated: Repeated[Pattern[x,Blank[]]]//InputForm (*(x_)..*) The reason it breaks in the FE is that the FE treats the x_. as a single token: RowBox[{"x_.", "."}]. And that's absolutely correct: see ...


8

You just got to remove the initial data:image/jpeg;base64,, everything after that is base64 encoded pixel data. data = Import["https://pastebin.com/raw/KHE6A3gR", "Text"]; data = StringReplace[data, "data:image/jpeg;base64," -> ""]; ImportString[data, "Base64"]


8

This is what you want ? StringJoin[Riffle[Partition[Characters[#], 2], "&&"]] & /@ {"x1x2", "x1", "x1x2x3", "x3", "x4", "x1x2x3x4"} (* Out: {"x1&&x2", "x1", "x1&&x2&&x3", "x3", "x4", "x1&&x2&&x3&&x4"} *)


8

lst = {"x1x2", "x1", "x1x2x3", "x3", "x4", "x1x2x3x4"}; You can use a combination of StringRiffle and StringPartition StringRiffle[StringPartition[#, 2], "&&"] & /@ lst {"x1&&x2", "x1", "x1&&x2&&x3", "x3", "x4", "x1&&x2&&x3&&x4"} Alternatively, you can use StringReplace: StringReplace[lst, ...


8

The following will give you a long string of text using common words separated by a space; it is very fast after the first execution (which loads some indices): StringRiffle@RandomWord["CommonWords", 100] "dexterous calibration ethical nocturnal misfortune ruining commodious refreshing gable arithmetic sacristy doorknocker thread measles pittance ...


8

rules = {"a" -> "0", "OverBar[a]" -> "1", "b" -> "1", "OverBar[b]" -> "0", "c" -> "0", "OverBar[c]" -> "1", "d" -> "0", "OverBar[d]" -> "1", "e" -> "0&...


7

(Extended comment, not an answer. From the comments to it by OP I do no see the point expanding it further into full blown answer. Thanks to everyone who reacted to it...) Procedure outline Ingest text data. I used Air BnB review data from this site : http://insideairbnb.com/get-the-data.html . Approx. 16000 reviews. (Out of ~500K from Austin, TX and Fort ...


7

Use the the syntax where you specify the order: DateObject[{"06.02.97",{"Day","Month","YearShort"}}] DateObject[{1997, 2, 6, 0, 0, 0.}, "Instant", "Gregorian", -7.]


7

Yes, so first we convert them into quantities: quantities = Interpreter[Restricted["Quantity", "Megabytes"]][st] Now we can eg add them with Total@quantities or sort them with Sort@quantities. In the Interpreter specification, we restrict the type of quantity to one that is compatible with "Megabytes". This is because otherwise, "4.0K" is normally ...


7

{First[#], Rest[#]} & /@ ImportString[#, "Table"] & /@ l (* {{{1, {"atattaggtt", "tttacctacc", "caggaaaagc", "caaccaacct"}}, {61, {"ctctaaacga", "actttaaaat", "ctgtgtagct", "gtcgctcggc"}}, {121, {"gcagtataaa", "caataataaa"}}}} *)


7

This only makes minimal use of string patterns (as with Jason B.'s answer, it builds on StringContainsQ), but it uses Fold in a way I don't think I've ever seen it used before, to get the elements of a list that satisfy a bunch of predicates. It is terribly efficient? Maybe not. But I still think it's kind of cool: Fold[Select, DictionaryLookup[], ...


7

Select[Length @ # > 1 &] @ SequenceSplit[data, p : {{_, 0} ..., {_, 1} ..} :> p] {{{"Call", 0}, {"Call 2", 0}, {"Response", 1}}, {{"Call 3", 0}, {"Response", 1}, {"Response 2", 1}}} SequenceSplit[data, {p1 : {_, 0} ..., p2 : {_, 1} ..} :> {p1} -> {p2}] {{{"Call", 0}, {"Call 2", 0}} -> {{"Response", 1}}, {{"Call 3", 0}} -> {{"...


7

crl={{"Call",0},{"Call 2",0},{"Response",1},{"Call 3",0},{"Response",1},{"Response 2",1}}; SequenceCases[crl,{c:{_,0}..,r:{_,1}..}:>First/@{c}->First/@{r}] {{Call,Call 2}->{Response}, {Call 3}->{Response,Response 2}} crl1={{"Bad Response",1},{"Call",0},{"Call 2",0},{"Response",1},{"Call 3",0},{"Response",1},{"Response 2",1},{"Bad Call",0}}; ...


7

StringCases["223", a : DigitCharacter ~~ b : DigitCharacter /; Evaluate[Unequal @@ (ToExpression /@ Characters["ab"])]] {23} Compare the evaluation of the three forms using Trace: Trace[StringCases["223", a : DigitCharacter ~~ b : DigitCharacter /; Unequal[ToExpression /@ Characters["ab"]]] ] // Column Trace[StringCases["223", a : ...


6

ToExpression is very fast for correct Mathematica syntax input. So the key idea is to create an input string for ToExpression that delivers the expected result for the huge string database in one go: StringData // Extract[{All, 2}] // StringRiffle[#, {"{{", "Nothing},{", "Nothing}}"}] & // ToExpression The odd looking "Nothing}" in ...


6

ToString[{"a", "b"}, InputForm] (* "{\"a\", \"b\"}" *) (thanks @kglr for golfing!) If you need to get rid of the space between the strings in the string (as per your specification), then use a StringDelete[" "] operator: ToString[{"a", "b"}, InputForm] // StringDelete[" "] (* "{\"a\",\"b\"}" *)


Only top voted, non community-wiki answers of a minimum length are eligible