There's a particular paragraph in my document and I want to replace its content completely with something else programatically. Is there any function to do this? I need something like this:
app.activeDocument.stories[7].paragraphs[0]. = "blah blah blah";
where is the function that would allow you to replace the content of the paragraph in question to "blah blah blah." I bet this is possible but am not aware of the functions available.
The property you need to use is "contents".
myParagraph.contents = "Bla bla bla";
Related
I have files like this:
something something other text MARKER bla bla something
something else something MARKER foo bar etc pp something
I want to replace something with another thing, but only before the MARKER. So the replace should yield:
another thing another thing other text MARKER bla bla something
another thing else another thing MARKER foo bar etc pp something
How do I do it in vim?
For example,
:%s/something\ze.*MARKER/another thing/g
See :h /\ze
A single cell will contain a string like the following:
[{"Code":"C015","Index":0,"Message":"blah blah blah","FailSeverity":2},{"Code":"W012","Index":0,"Message":"blah blah blah","FailSeverity":1}]
I am interested in pulling out all of the Codes from the single string above. I.E. I want the "C015" and "W012" from the example above and nothing else.
I've seen the Substring() function but am not too sure of how to implement it in this scenario or that I fully understand it as a function.
For something like this I think you've want to employ a good tally based string splitter function. In this case I'm using Jeff Moden's DelimitedSplit8K
DECLARE #String VARCHAR(8000) = '[{"Code":"C015","Index":0,"Message":"blah blah blah","FailSeverity":2},{"Code":"W012","Index":0,"Message":"blah blah blah","FailSeverity":1}]';
WITH
cte_GetCodes AS (
SELECT
CodeValue = CASE WHEN LAG(dsk.Item, 2) OVER (ORDER BY dsk.ItemNumber) = 'Code' THEN dsk.Item END
FROM
dbo.DelimitedSplit8K(#String, '"') dsk
)
SELECT
*
FROM
cte_GetCodes gc
WHERE
gc.CodeValue IS NOT NULL;
Results...
CodeValue
----------
C015
W012
How to remove some text in edit.text with exceptions?
I want to remove all text except the text that I want to keep.
ex : "THIS IS THE TEXT"
Then i want to remove all text except "THIS" and "TEXT"
After removing the result will be like this:
"THIS TEXT"
I was wondering if StringReplace() wouldn't be working if the text have a changeable context. Or maybe StringReplace() will be working in this case with another method?
You can do this
string s = "THIS IS THE TEXT";
string v = s.Replace("IS THE", "");
Hopefully, it will solve your problem
I'm trying to split a string in multiple lines (such as the text of a song); I'm working in the localizable.strings.
I'd like to do something like this:
"TITLE_SONG01" = "It's my life";
"SUBTITLE_SONG01" = "";
"TEXT_SONG01" = "It's my life" +
"is now or never";
but it doesn't work because data isn't in the correct format. Can anyone help me?
You can do that by inserting "\n" where you want the new line to start. For example:
print("Hello\nWorld")
Which will output the Hello on one line and World on another like this:
Hello
World
I need to import text from txt file with some variables. I use BufferedReader and File Reader. In code I have :
String car = "vw golf";
String color = "nice sunny blue color";
And in my txt file:
I have nice " +car+ " which has "+color+".
My expected output :
I have nice vw golf which has nice sunny blue color.
My actual output is :
I have nice " +car+ " which has "+color+".
If I've understood correctly, what you want to do is replace " + car + " with the value of your car string and likewise for colour. You've tried to do this by writing your text file as if it were a command to be evaluated. However, that won't happen - it will just be outputted as is. I'm going to assume you are using c#. What you need to do is, prior to outputting your string, parse it to replace the markers with the variables. I would recommend you get rid of the double quotes in your text file. You could then do something like this:
string text = this.ReadTextFromFile();
string ammended = text.Replace("+car+", car);
As mentioned, this is assuming you remove the double quotes from your text file so it reads:
I have nice +car+ which has +color+.
Also, you don't need to use the + symbols, but I suppose they are a good way of designating a unique token to be replaced. You could use {car} in the file and then likewise in the Replace startment, for example.
I may not have properly understood what you wanted to do, of course!
Edit: Incase of confustion,
this.ReadTextFile();
was just a short hand way of saying that the text variable contains the contents as read from your text file.