Pattern matching with DeleteCases
I'm using Mathematica 14.0 and I'm having a pattern match problem with DeleteCases. The example below illustrates the problem. I define a test string followed by two patterns that both nominally match...
View ArticleButterflied Strings Shortest Character Solution
The shortest character solution for Butterflied Strings on Wolfram Challenges according to the CODE CHARACTERS functionality is 40. I have a solution with 42 characters, namely ButterflyString@x_:=...
View ArticleProblem with WordBoundary in string patterns
I am trying to extract from a string all words that end with "-man", but the problem is that WordBoundary does not seem to work as it returns whole string ignoring actual word boundaries.Here is the...
View ArticleWhy is StringSplit dropping empty entries? [closed]
I am parsing a CSV and whenever the trailing records are empty:StringSplit[",2,,4,,",","]I get:{"2", "", "4"}But I was expecting:{"", "2", "", "4", "", ""}Is there an option for StringSplit to do that?
View ArticleHow to convert LaTeX to expression without interpreting variables as products?
I need to convert some LaTeX code to mathematica expressions. So far I have usedToExpression["ab", TeXForm]yielding ab, i.e. mathematica variable with the name "ab". This is what I want. However, the...
View ArticleHow can I transform the string to a list?
As you can see from the picture, when I use StringReplace function, the list is converted to a string. How can I get the list form back? And the String "-" is necessary (Cuz I just know one way to...
View ArticleCompressing a file's name string
I was working with files where each name records a lot of information about what is in its respective file and wanted to compress it a little bit. So I wanted to change it's 'base'.And I noticed that...
View ArticleHow to improve Burrows-Wheeler Transform performance?
I have implemented the Burrows-Wheeler Transform as below:eofChar = FromCharacterCode[255];BurrowsWheelerTransform[string_] := With[{s = string <> eofChar}, StringJoin @@ (StringPart[#, -1] &...
View ArticleReplace number in string with ? and /;
I am trying to make the following:StringReplace[{"A4", "A#3"}, {"A" ~~ x_ -> "B" ~~ x}]This should replace A4 by B4 but leave A#3 untouched. How can I do that? I tried to use ? and /; with a test...
View ArticleSublist creation, splitting and joining
I have a not very usefully-formatted string list and I would like to create certain sublists from it.lis = {"F","aa","b","12","c","d","e","2","T","n","1","m","o","3","F","r","s","23","q","0"} The...
View ArticleHow to remove quotation marks in Table List
I have Import a .txtData = Import["files.txt", "Table"];But the Data have the following format, I Cann't get the first column of Data eg. a,b,c, how to get rid of quotation marks in Data?{{"a,10,20"},...
View ArticleFinding the index of certain strings in a list
I'm actually using a dataset of much greater dimensions and length but I simplified my problem of string patterns in order to ask this question.dates = {"2018-01-01 22:00:00", "2018-01-01 22:30:00",...
View ArticleReplace $n$-th occurrence with number $n$
How can I replace $n$-th occurrence with number n for string/for list?For string :StringReplace["amkwajefiwaeah", "a" -> "A"]"AmkwAjefiwAeAh"But how can I get"1mkw2jefiw3e4h" or"A1mkwA2jefiwA3eA4h"...
View ArticlePartition string into chunks
This seems like it should be trivial, but how do I partition a string into length n substrings? I can of course write something likechunk[s_, n_] := StringJoin[#] & /@ Partition[Characters[s], n]so...
View ArticleJoin non-digit character strings
I have a list:lis = {"20","ab","Cd","10","E"}in which I would like to join adjacent elements if they are letters and not digits, to give:res = {"20","abCd","10","E"}Again thanks for any help!
View ArticleSort Column as a Row
I havea = {1, 2, 3, 10};b= {2, 3, 4, 8};t= Do[If[a[[i]]+b[[i]]>3,Print[a[[i]]],"No"],{i,1,4}];2310I need to get the result; t={2,3,10}
View ArticleFind Roman numerals up to 100 that do not contain “I"
The question is from Elementary Introduction to the Wolfram Language, section 28 Tests and Conditionals: Find Roman numerals up to 100 that do not contain “I”.What am I doing wrong that the following...
View ArticleFinding a subset in the set of the digits of Pi
Well, I want to find the first position where the digits of Pi are {a,b,c,...,z}. So to find the first n digits of Pi and put them in listform I...
View ArticleUsing NumberString, DigitCharacter, or a similar directive to find all string...
I have a text file containing many, many lines of text like test in the following:test = "word 123 456 7890.000 0.12000";I would like to extract all of the "string representations of integers."...
View ArticleDecomposing input to two list
Suppose I have $j[1,a1,a2,a3,a4,a5]$, I want to extract this as $\{1,\{a1,a2,a3,a4,a5\}\}$.--My first trial:Using the command Split, I can make Split[List @@ j[1, a1, a2, a3, a4, a5]] {{1}, {a1}, {a2},...
View Article