How to get a substring that comes after a certain character with LibreOffice's RIGHT function? - libreoffice

In the cell A2 I have a surname AARY followed by an open parenthesis and a forename (Max.
      |               A                              |                        B
------------------------------------------------------------------
1    |    Last name of the artist    |          First name of the artist
------------------------------------------------------------------
2    |    AARY (Max                       | Here goes the forename 'Max'
I wanted to extract the forename without the parenthesis by using the command =RIGHT(A2,LEN(A2)-SEARCH("(",A2)), but I get the Err:508 error in bracketing.
When I add the bracket at the end of the formula, I get the LibreOffice Calc found an error in the formula entered.
Why is this happening?

Commas may not work in LibreOffice depending on your settings. Semicolons work no matter what the settings are, so they are preferred unless interoperability with MS Excel is necessary.
=RIGHT(A2;LEN(A2)-SEARCH("(";A2))

In Excel:
=MID(A2,FIND("(",A2)+1,9999)
(the 9999 should accommodate most names)

Related

How to go to a specific character offset

I'm on MacOS 10.15.7, using BBedit 13.5.5. Under "Go ->" There is only Go to Line Number. I want to go to character 145 of the file.
Here's a crib from page 103 of the user manual (you'll find it on the Help menu):
Alternatively, you can jump to an absolute character offset, by using the ‘line:column’ syntax but leaving the ‘line’ blank or specifying it as zero. For example, entering “0:1500” or “:1500” will cause BBEdit to place the insertion point before the 1500th character in the document. (The range syntax works too; so you could use “0:12-0:56” to select characters 12 through 56.)
Correct - if you select Go from the menu, it says, after selecting Line Number:
:C character offset C in document
So, :20 goes to position 20. But, I have found it is off a few characters, perhaps it is not counting line feed.

Is there a way to select everything right of first string in line

So I got a body of space separated text and I'm trying to mine names. These names are the first :
Tsuru Stork greeting for a long last life. Unisex
Yama Mountain; Restrainer; Unisex
Yuka A bright Star Unisex
Yumi A beautiful archery bow Unisex
Yuna The archer Unisex
How can I select everything right of the first string in each row?
I figured out how to select the names themselves with this:
(\n+)[A-Z]{1}\w+
But there doesn't seem to be an easy way in word to highlight, copy then paste the selection.
In summary, how do I select elements after the first string in a new line?
If this is done in Microsoft Word then try the following:
*^13
This stands for:
- A space character.
* - Match any sequence of characters.
^13 - Match a newline character (ASCII 13).
If I understood your question correctly, this will highlight all text to the right of the first word in each line. See the below screenshot (don't mind the Dutch pls.):
If you actually need to make sure you select everything after the first multiple space seperation, then maybe use {3,4}*^13:
Again, don't mind the Dutch along with the locale parameter delimiter (semi-colon) in the occurence indicator. This will be a comma if your locale is English.
You can use regex like : (^\w+)
^ start of line
\w+ matches world char one or many times
Demo

Number and letter numbering of tables in word with cross-referencing

How do I get a smart numbering system as shown below? Whenever I have a new table, I want the numbering to rise.
If, on the other hand, I add a row to the table, I would like to add a letter in behind the numbering.
Is this possible?
I have startet using Field Codes and Sequences, and I believe it is the way to go.
I know the numbering without the letters can be obtained by
Number #{ STYLEREF 1\s}{SEQ Table \# "00"}
I also know that alphabetic numbering can be made by using the \alphabetic command.
I am just not sure how to combine them. Also, I would like to make cross-references to the table captions.
You can achieve this with Word's built-in numbering - no need to resort to a complex combination of fields that you'll need to manually update.
I'm going to outline the very complete approach...
On the Home tab: Paragraph/Multilevel list/Define new list style.
Enter a name for the style, then from the Format button choose Numbering; click More.
With Level 1 selected, choose the style with which you want to link the numbering (Heading 1, for example)
In the "Enter formatting for number" field type any text you want to have appear before or after every number. (According to your picture: Header in front of the number 1 with grey shading already in the box.)
Select Level 2, choose the style with which you want to link the numbering (Heading 2, for example)
In the "Enter formatting for number" field type in front of the number (2, grey shading): Number #00
From the "Include level number from" dropdown, select level 1. The number from Level 1 will be inserted between the last 0 and the grey-shaded 2.
If necessary, change the alignment settings (you probably don't want the indent inside the table cell?)
Now, when you apply the Heading styles the numbering will be applied automatically. If you don't like the formatting of the Heading styles you can change the style definition(s). Since you created a numbering style, you can also change these settings by going again to the Multilevel numbering dialog box, right-clicking the numbering format you created and selecting "Modify".
I believe the following field code approach will give you the numbering indicated in your sample image (where the table numbering restarts for each Heading 1 paragraph. However, it will probably only work for "in-line" tables, not floating tables or tables in text boxes and so on.
The main aim here is to ensure can insert exactly the same field codes for each new "Number#" that you need, but to achieve that you also have to put some codes at the beginning and end of each table. You will also need to select and re-execute all the field codes twice to ensure that they are updated properly - this is the kind of disadvantage that Cindy Meister's Answer mentions.
At or before the beginning of each table, put the following fields. (If you are already putting a table caption before each table, you could do this slightly differently.)
{ SEQ tbl \s 1 \h }{ SEQ ltr \r0 \h }
This increments the table number, resetting at each Heading 1 paragraph, and resets the letter number to 0.
For every "Number #" you want in a table, use the following fields:
Number #{ STYLEREF 1 \s }{ SEQ tbl \c #00 }{ SEQ ltr \h }{ IF { REF "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" } > 1 "{ SEQ ltr \c \*alphabetic }" "" }
This inserts the appropriate Heading number and the table number, and increments the letter number. It then looks at a bookmark that contains the number of "Number #" entries in this table. For example, if Heading 1 is numbered 4, and this is the thrid table under that heading, the bookmark will be called "chap1tbl4". If the bookmark's value is greater than 1, the appropriate letter will be appended.
But we have to create that bookmark and value, which we can only do after all the "Number #" fields for that table. So at the end of each table, or immediately after the table and before any new Heading 1 paragraph, you will need the following field codes:
{ SET "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" { SEQ ltr \c } }
The thing is that Word evaluates field codes in the sequence they appear in the document. So when Word first encounters the { REF } field in the table, the bookmark will have no value. So the first time you select all the fields and execute them, you may see the wrong answer. After you have done that, the bookmark is created. Word will use the value most recently assigned to the bookmark, so the next time you execute the "Number #" fields, they should work properly.
I think to achieve what you wanted using the general approach given in Cindy Meister's Answer, you would need to have two separate Heading levels, one for the Numbers without letters,and another for the numbers with letters. The user, or some VBA (say) would then have to decide for each table which Heading level to use. But even if that is the case (and she may have something else in mind), it may still be an operationally simpler approach than the field-based one. I suspect only you are in a position to decide.
There may be a simpler field-based formulation, but IME the basic problem is that you cannot test the "final value" of a SEQ or SET field, only the value it has at the point of execution. For example, if there was a \f flag that let you test the final value of a SEQ field, you could use
{ IF { SEQ "chap{ STYLEREF 1 \s }tbl{ SEQ tbl \c }" \f } > 1 .... }
to test the number of "Number #" entries in each table, without having to have that awkward end-of-table SET field.

How to do search and replace involving fields in Microsoft Word?

I have a Word document with fields of the reference variety, which occur in the form "[field].[field]"--in other words, there's a period between the two fields. I want to globally replace this with a space.
Word offers the ^d special character to search for fields, but for some reason the query "^d.^d" does not find anything. However, ".^d" does. Now comes the problem, however--what do I specify as the replacement text in order to retain the field code? If using regular expressions, I could use a "Find What Expression" such as \1, but with regexp ("wild card") mode the ^d is not permitted.
I guess I could write a macro...
I would like to add to Bibadia's solution.
An example of an index entry field; we want to change a name we misspelled.
Make sure hidden formatting is displayed (toggle with SHIFT+CTRL+F8).
Make sure wildcards option is not selected. To search for fields, use the opening and closing field braces code (optionally use ^w for spaces, as Bibadia suggested):^19 XE "Deo, John" ^21
Replace won't recognize field braces character, but will allow to insert the clipboard's content. ;). To do that, insert in text the correct entry. CTRL+F9 to insert field and type:XE "Doe, John"
Select the field above and copy
Use ^c in the replace box
Hit Replace All
Ta-da!
It's usually better to go the macro route when finding fields because, as you say, the find algorithm that Word uses doesn't work the way you might hope with fields.
But if you know exactly what the fields contain, you can specify a search pattern that will probably work (however not in wildcard mode).
For example, if you want to look for figure number field pairs such as
{ STYLEREF 1 \s }.{ SEQ Figure \* ARABIC \s 1 }
(which would typically be the same set of fields everywhere in the document)
If you only really need to look for the following:
{ STYLEREF 1 \s }.<any field>
you could ensure that field codes are displayed and search for
^d STYLEREF 1 \s ^21.^d
or
^19 STYLEREF 1 \s ^21.^19
If you need to be more precise, you can spell out the second field as well.
"^d" only works for finding the field beginning, not the field end.
It's a shame that ^w wants to find at least 1 whitespace character because otherwise it would be more robust to look for
^19^wSTYLEREF^w1^w\s^w^21.^19
Perhaps someone else knows how to work around that without using wildcards?
Torzaburo,
I suggest that you do this using a macro. You can start by recording the macro, and later refining your processing steps within the macro.
First turn on the hidden characters by navigating to Home > Paragraph > toggle the show/hide Paragraph symbol. Also, select all and toggle the field codes on (right-click and select "Toggle Field Codes".
Open a new blank Word doc in addition to the one you have open. You will use this later. Start the macro recording and find the field using the "^d" (field code) as you said.
When the field is found, copy only the field text within the brackets, and not the full field reference. While the macro is still recording, ALT + TAB to the new blank document and paste the field code in as plain text.
At this point, do the necessary find & replace processing to the field codes. Highlight the processed field codes, copy, ALT + TAB back to the original document, and paste back between the { } brackets.
Stop the macro recording. Add any further custom processing to the macro VBA.
Select-All and re-toggle the field codes. Update the field codes.
You don't need a macro. Just toggle all field codes on by using Alt+F9. Then do a find and replace for what you want to change. Once the replacement is complete, use Alt+F9 again to toggle the field codes back off.
Disclaimer: I didn't originate this solution, but it's clean and elegant and I thought it should be included here:
(Adapted from Search & Replace Field Codes in Word):
Create or find a single instance of the field you want to convert text to
Toggle Field Codes visible (AltF9)
Copy the code for the field you want to use to the Clipboard (highlight and CtrlC)
Open the Replace dialog box (CtrlH), insert the text you want to replace in the Find What box and then enter ^c in the Replace With box.
This will replace your text with the contents of the Clipboard, turning it into the field code you copied in step 3. It also copies formatting information (font, color, etc.), to control how the field will appear when hidden. (Caveat: I've tested this with Word 2003 under Windows 7 only.)
Coming in late on this, probably way too late for Beth (sorry Beth). And this may not be quite what Beth was looking for. But for anyone interested ...
It sounds like Beth may have created captions throughout the document using INSERT CAPTION (hence the presence of field codes). This means these captions will have been (automatically) created in CAPTION style.
To globally replace the separator "." with " " (space) in such captions, take two steps:
[1] Go to REFERENCES | INSERT CAPTION, then click on NUMBERING and replace the SEPARATOR "." with "EM-DASH". This will replace all separators in captions for the selected label in the CAPTION Window. If you have other labels in use in the document (e.g. FIGURE), select the other labels one by one and repeat this process.
[2] Do a find/replace searching for special character "em-dash" (^+) in style CAPTION, replacing with " ". Click REPLACE ALL.
Voila!
NOTE: This presumes that em-dash does not appear in the caption text anywhere. If it does, then you'll need to do a pre- and post- "fiddle" to ensure these em-dashes are not touched by the global replace above.
The "pre-fiddle" is to do a global find/replace across captions, replacing the em-dash ("^+") with some other string (e.g. "EM-DASH") that doesn't ever occur in any caption's text. Then you do the separator change as described above. Finally, the "post-fiddle" is to restore the em-dashes that were in the captions, by doing a global replace of the string "EM-DASH" with the actual em-dash character "^+".

format number in ssrs report

argh!
Can't stand it that i can't figure it out myself....
i've used this in the formatting of a number in my report:
'€' #,0.00;('€' #,0.00)
and that formats to € 1,212.89
which is not exactly what i want, because i want € 1.212,89
regardless of the regional setting of the server.
So i tried this
'€' #.0,00;('€' #.0,00)
but that gives me this:
1.212.890
Typing this i realize that i don't know what the # and the . and the , mean in the format string.....
You can find the definition of the comma and period dynamic behavior here:
http://msdn.microsoft.com/en-us/library/0c899ak8.aspx
I think the best way to reliably get what you want is to hard code a locale into the expression for this field.
= (new Decimal(11123.55)).ToString("€#,0.00;(€#,0.00)",
new System.Globalization.CultureInfo("es-ES"))
This will always use the comma as decimal, and period as millions, thousands &c.
There are ways to be more dynamic and always return in the clients local set format, that would usually be preferable.
I know this is an old thread, but in case someone needs it, there is an easiest and most proper way to do it :
Right click on the Textbox of your expression
Select "Number" in the popup "Text Box Properties"
In the "Category", select "Number"
Tick the "Use 1000 separator
Click OK
To "customize" your '1000 separator':
Select the Textbox of your expression
In the Properties on the right, apply the right culture in the "Language" property.
E.g. Select "fr-CH" to have 123'456 otherwise the default is 123,456 as English separator.
Try this out. It will format your value to the correct number of decimal places.
=format(1212.89,"€#,#.00")
For indian currency, in the field value use like =Format(Fields!ServiceTaxAmt.Value,"##,##,##,###.00") and change the language value to hi-in for report property.
You can use the format € #,0.00 and set the language of your report to de-DE by clicking outside of the report area and in the right properties pane go to Localization -> Language.
This Works correctly with [set Language as hi-IN and Format as "##,##,##,###.00"]
Appreciate your Efforts
Also Same can be achieved by following Steps
Go to Text Box Properties
Select Number category in Number Tab
Check the check box beside [Use 1000 separator(,)]
Click Ok