Quantcast
Channel: Active questions tagged string-manipulation - Mathematica Stack Exchange
Browsing latest articles
Browse All 192 View Live
↧

How 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 Article


Selecting sublists from a ragged array of lists of strings

A ragged array of strings with a mix of sublists is processed to output some sublists and not others.The sublists to output have a date, data, and information; in no particular order.The information...

View Article


Pruning units from oscilloscope data

I'm trying to import some data in a .txt file which contains numbers and words. I import a list which consists of four rows of measured data acquired with an oscilloscope, but the acquisition program...

View Article

Defining a string based sort function

I'm having a bit of trouble figuring out the right Sort syntax to use on a list of lists. Consider the following list:list={ {"B0T", "Ch72", "T0p36K", "Vdiv2047p92", "Vg75V"}, {"B0T", "Ch70", "T0p28K",...

View Article

Remove words from a string that contain special characters

I have a string like this:string="there is a humble-bee in Hanna's garden";Now I want to exclude those words that contain "-" and "'". My own solution would...

View Article


How to scramble a string of text?

How to implement foo function which works like this:foo @ "abcdef""fdbace"Steps: "bacdef", "cabdef", "dbacef", "ecabdf", "fdbace"Reverse the first two letter of the string "abcdef" which will give...

View Article

Extract substrings with defined length from a string

I have a string like this onestr = "this and that but also thit and that";Now I want to extract, the first 3 letters before and after " and " so that the outcome is{his and tha, hit and tha}I tried it...

View Article

Elegant 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 Article


Use string as name of list

I want to use a string as the name of a list. I'm reading in text file names from a directory. Each of those text files has a 1-dim list of things. I'd like to create a list from the file name which...

View Article


Splitting a string into substrings of length 1 and 2

There is already a thread on how to split a string into equal sized chunks.I'm wanting to split a string into sets of substrings of length 1 and 2.For example, if I have the string "123456", my list...

View Article

Randomly reversing a substring

I was thinking about how to make this with the StringReverse, but I failed:I have a sequence of (for example):str = "FDSRTYNHFNKHLIUHG";I wish to reverse a randomly long contiguous sequence of...

View Article

read Python-generated data file

I've read similar-but-not-quite-the-same questions : I have to read a python-generated data file which contains complex numbers. So, the numbers appear as (real+imag j). And of course Mathematica read...

View Article

A function that maps Held symbol to string

Rougly my question is about constructing a function that maps Hold[var] to "var"even when var has an assigned value. In details :In[1] var=22; A=Hold[var];Can we construct a function F such thatF[A]...

View Article


Split a String by minus and zero

How can a String like0.0002230.0012730.000296-0.0014380.0011270.0014690.001457-0.001017`be converted to{0.000223, 0.001273, 0.000296, -0.001438, 0.001127, 0.001469, 0.001457, -0.001017}

View Article

Remove expression with matched braces from string

I am writing a LaTeX document where the custom command \chg{...} highlights changes in some color. Here I am, with a document of about 50 of those. Sure, one could just remove "\chg" everywhere, but...

View Article


How to extract citations from a document

I would like to extract citations from a document. I can use the following:txt = "Lorem ipsum dolor sit amet Name0 (2000), consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et...

View Article

NYT Spelling Bee puzzle

I've written some code that provides answers to the daily NYT Spelling Bee puzzles which ask you to find words that can be constructed from 7 given letters, one of which must be present in each...

View Article


How to separate a filename from its extension [closed]

Is there a function that separates a filename from the extension? E.g.MyNotebook.nbwould become{ "MyNotebook", ".nb" }I looked at FileNameSplit[], but that leaves "MyNotebook.nb" as the last...

View Article

Turn string with () as function brackets into expression

I have a text file with an equation where all the brackets are formatted as (). For example I read in the equation 2*(Re(a)+Im(b)) as a string. Now I am wondering if I can make this into an expression...

View Article

How to get the desired LLM response in string robustly with and without using...

I am trying to query a large language model from VS code using WolframEngine.However, ImportSting with JSON options does not work in extract the desired output string of the LLM response. So I use the...

View Article

Image may be NSFW.
Clik here to view.

How to properly write fraction in style

I would like to write the following for the legend of a curve :$$ Theta = \frac{\pi}{2}$$Where the value $\frac{\pi}{2}$ is actually in a variable named $Theta$ (same name as the text on the lhs of the...

View Article


Match two lists based on same elements

I have two large lists:list1 = {{a,v},{a,h},{b,v},{b,k},{c,t},{c,r},{d,r}};list2 = {{v,dc},{v,rt},{h,kl},{h,oi},{h,po},{k,ö},{k,dc},{t,re},{r,qw},{r,ay},{r,ül}};Now I want a list that matches both...

View Article


How to speed up ToString[#,TeXForm]&?

Try the following code to convert the expression to LaTeX codef = Expand[(x/2 + y/3 + z/5 + 1/7)^20];str = ToString[f,TeXForm]; // AbsoluteTimingIt took about 1 minute, while sympy.latex only took 0.6...

View Article

How to parse out a word's position in a data set

I'm trying to find better ways to import data. My data set is a CSV that contains a parameters at the end of the file. For example in this two part list I want to find the position at which the word...

View Article

Converting variable value to a string [duplicate]

I can run this with no problem:Import[NotebookDirectory[] <> "a10.mx"];Instead of that, I want to describe 10 with a variable as k,k = 10;Import[NotebookDirectory[] <> StringForm["a``.mx",...

View Article


How to set to 0 all terms in a matrix which contain a minus, revisited

The previous question How to set to 0 all terms in a matrix which contain a minus seems to have a wrong answer. For the matrixM = {{-ai - ar + ba s - \[Mu], bi s}, {ai, -\[Gamma]i - \[Delta] -...

View Article

Escaping multiline strings in Mathematica

I want to assign long multi-line strings in Mathematica. Is there a way of delineating a block without having to escape each instance of '"' with '\"' and each line ending with '\'?i.e. In other...

View Article

How to delete line breaks in imported data

I am having a lot of issues trying to import data into mathematica and then clean the data so that mathematica recognises it. The data is a set of permutations, which I would like to express as...

View Article

Image may be NSFW.
Clik here to view.

Duplicated points not labeled when presented to ListPlot as point->"label"

A minimal working example is given via:{{{1, 4} -> "A"}, {{2, 2} -> "B"}, {{3, 1} -> "C"}, {{3, 7} -> "D"}, {{4, 5} -> "E"}, {{4, 5} -> "F"}, {{5, 3} -> "G"}, {{6, 6}...

View Article



Image may be NSFW.
Clik here to view.

Displaying a string on fixed-width lines

Is it possible to format/style a string/text so that it is displayed in lines of fixed character length like on image without converting it to list of characters?str = Mod[Range[0, 105], 26] /....

View Article
Browsing latest articles
Browse All 192 View Live


<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>