Partition 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 ArticleIntra-Symbolic Wild Card Pattern Matching
I have the following custom expression structure I am parsing:Theorema`Knowledge`Q$TM[ Theorema`Language`VAR$[Theorema`Knowledge`VAR$x$TM]]I already was able to match the inner structure so that I can...
View ArticleRule-based deletions from string list
I have a list of strings:lis = {"a","b","c","12","d","q","r","X","s"}I'd like to delete list members starting with "X" moving backwards through the list from "X" until a list member that's a digit...
View ArticleCoverting .nb file code content to string type using NotebookImport
For my work I need to import the notebook and get all the contents from the code cell. For this task I chose ToString/@NotebookImport[file,"Input"->"HoldExpression"]."Input"->"HoldExpression" is...
View ArticleHow to define a mixed pattern consisting of string and regular patterns for...
I'm kinda stuck here, and I could really use some help:I want to define a function, let's call it quarterValue, that accepts a Rule as an input and returns an appropriate expression as output.A...
View ArticleSplitting a list by specifying section headers
I have a list of strings called mylist:mylist = {"[a]", "a", "a", "[b]", "b", "b", "[ c ]", "c", "c"};I would like to split mylist by "section headers." Strings that begin with the character [ are...
View ArticleHow to extract a consecutive list of substring from a string?
Given a list of strings:data = {"2894;Hot Pink;53:09:44;1449714","17456;Dark Cyan;19:06:42;6929227","5147;Lime;54:11:55;5247632"}(Words are separated by ";", the number of words in strings are equal....
View ArticleMatch sequence of zero or more characters except a given character
This looks like it should be simple: I want to match an "i" followed by an "o" with an arbitrary (possibly zero-length) sequence of characters in between, unless that sequence also contains an "i"....
View ArticleConvert String to List of Numbers
I want to create a function that when a string is entered it will turn it into a list of numbers, these numbers are the numerical form of the characters in the string.e.g. a=1, b=2, c=3, d=4 and space...
View ArticleElegant and fast way to join all string sequences
I want to do what title says:{"a","b",1,2,3,4,"a",2,2,2,"edg","?"} => {"ab",1,2,3,4,"a",2,2,2,"edg?"}in the most elegant way. For example one replacement rule for ReplaceAll.I have manage to do...
View ArticleFind the position of a string element, knowing only part of the string
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....
View ArticleSwap first and last names in a list
Edited to fix an inconsistency in the given example data format.I'm trying to write a simple function to load in a csv list of names which is formatted as "Lastname Firstname Initial " and convert it...
View ArticleConverting a string containing whitespace-delimited numbers to a list of numbers
Suppose I have a string str that contains only whitespace-delimited real numbers:str = " 0\t1.46604\t1.44829\t12.0546\t1.57075\t1.64044\t12.0489\t1.58142";I would like to convert str to a list of real...
View ArticleHow to convert RowBoxes into list of math expressions?
I have following RowBox which represents Step By Step solution of undefined integralRawBoxes[StyleBox[FormBox[StyleBox[GridBox[((StyleBox[GridBox[((Cell[TextData[(StyleBox['Take the integral:',...
View ArticleIsolating characters in a string
I'm struggling to find the right function in mathematica to isolate specific characters in a string. I have got a formula as string (I imported it from an excelfile) like this: y = 0.97*x1 + 0.521*x2 -...
View ArticleRemoving non-word characters in certain parts of a string
I would like to ask how I can remove non-word characters from a string, but only in certain cases.I have read this article, so I know how to get the words out of a string. My text is however a bit more...
View Articlehow to extract the string using regular expressions
I have the list :a1 = {"struct name1 {","struct name2{","struct name3{","struct name4{","struct name5{","struct lastStruct{"}I tried to extract the struct names "name1",..."lastStruct" with this but I...
View ArticleHow to convert the element into Grid
I got the html source code for this element for this page in Wikipedia:<table class="wikitable"> <tbody><tr> <th><a href="/wiki/Hermann-Mauguin_notation" class="mw-redirect"...
View ArticleHow can I generate a list of combinations of string joins?
Suppose I have the string lists {'a','b','c'} and {'1','2','3'}. How do I get Mathematica to generate the list {'a1','a2','a3','b1','b2','b3','c1','c2','c3'}?
View ArticleDeleting all characters in a string that do not belong to a small set of...
Say I have a string {100 aa bbc%j%b%wa ajjcj11j0%2wj fc} with a lot of undesired characters or spaces in it, for example: {"", "%", "w", "j"}. I'd like to strip the string of these characters, with the...
View ArticleSelect elements from a list based on alphabetical order criteria
I have this code to generate the anagrams for a 6 letters word:letters = {"P", "E", "R", "I", "T", "O"};perms = Permutations[letters, {6}];list = StringJoin /@ perms;Which gives me 720 possible...
View ArticleReplacing whitespace in a list with comma and turning into sublists
I have the following list: l={"1 atattaggtt tttacctacc caggaaaagc caaccaacct61 ctctaaacga actttaaaat ctgtgtagct gtcgctcggc121 gcagtataaa caataataaa"}which I want to turn into:...
View ArticleHow do I make a single character bold?
I have a string of characters, like"CDABOZPVRYXSWQEGNILUTHMKJF"and want to convert it to a string in which the character at position p is bold. After doing this I want to leave the result in a table...
View ArticleImporting Specific Data from a Text File
I am quite new to Mathematica. I have a text file that upon importing has a repetitive structure with characters included. I need to extract only the following in numbers only (no letters, dash lines,...
View Article
More Pages to Explore .....