BJ190215P00020000
this is the string. I want to extract the left letters "BJ" (they are from 1 letter up to letters).
I think i need to find the position of the first digit, then apply LEFT function to get out the "BJ". (the letters could be 1-8).
is there a way to find the position of first digit in the string. OR, is there a better way to extract the letters before the first digit?
Try ...
=regexextract(A1,"\D+")
Related
Say...
cell 1 contains this text: 03400561, 1995-12-31
I need a way to split this cell into 2 raw text columns". i.e.
My expected/wanted output: cell 2 = 03400561 (as text) and cell 3 = 1995-12-31 (as text)
If I use the split function to do this (e.g. cell 2 = split(cell1,",")), it removes leading zero, and convert the yyyy-mm-dd text into a google date. I do not wish to have this conversion to take place. i.e. I just wanted straight and simple split a text, into columns of text (not numbers. not dates).
How do I do this out of the box? (I've tried google around but no luck). Is this even possible?
Side note: the "Data" => "Split text into columns" approach - no luck. It converts all numeric-like texts into numbers, and date-like texts into dates. I wish to have raw text throughout and no conversion like this to happen. How to do this?
Ugly as hell, but seems to work on your example. Basically enclose the separator with double quotation marks to force sheets into interpreting the data as text. Then remove them and use arrayformula() to cover all the columns:
=arrayformula(substitute(SPLIT(char(34)&substitute(U19,",",char(34)&","&char(34))&char(34),",",true,false),char(34),""))
CHAR(34) evaluates to double quotation (i.e. ") to signify text entry. Just be aware that the second variable includes a leading space (' 1995-12-31')
I am attempting to display lines that do NOT begin with one or more letters and do NOT end in one or more digits - using grep.
What I have so far is
grep '^[^a-zA-Z]'
This shows me all the lines that do not start with a letter, so a, abc do not show BUT abc (has a leading space) is shown, correctly, for example.
I am not sure how to include the second portion of this which is NOT end in one or more digits.
Thanks
Why not:
^[^a-zA-Z].*[^0-9]$
Note that this doesn't cover the case when only one character is present.
How to convert a range of arbitrary size, to it's string representation, to be later used using INDIRECT ?
ADDRESS only works for a single cell.
No scripting please :)
Only formulas.
EDIT 1 ;
Also assume the range is computed through a complex formula. So no cell addresses are available.
EDIT 2 ;
=ArrayFormula(IF((OFFSET(INDIRECT(PayStaff),0,10)>PayrollStart)*(OFFSET(INDIRECT(PayStaff),0,10)<=PayrollEnd),(OFFSET(INDIRECT(PayStaff),0,10)-PayrollStart),0)+IF((OFFSET(INDIRECT(PayStaff),0,11)>=PayrollStart)*(OFFSET(INDIRECT(PayStaff),0,11)<PayrollEnd),(PayrollEnd-OFFSET(INDIRECT(PayStaff),0,11)),0))
No sample sheet as this is a hypothetical type question.
Above is an actual formula I'm using, one of many in my efforts at fully automation. At any time, the range string in "PayStaff" can change, coupled with repeated but identical OFFSET calls, soon makes the formula unreadable. One of my ideas to solve the readability is to get the range-string of (eg: OFFSET(INDIRECT(PayStaff),0,10) ) and reuse it, shortening the formula and increasing readability. Also note, the example does NOT have size increase of range which I require as well.
But lets suppose that PayStaff = "A1:A10", where the number of rows can vary. Considering that OFFSET has 4 parameters, how to get the resultant range as a string? Is this possible?
I just used this to do something similar, hope this helps:
// <range here> = is the range you want to describe,
// can be output of some other formula but has to be a
// rectangle for this to work.
// Remove // comments and line breaks before pasting to sheet.
// concatenate top left corner with colon and bottom right corner.
=CONCATENATE(
// use address to get top left corner
ADDRESS(ROW(<range here>), COLUMN(<range here>)),
":",
// use address to get bottom right corner
ADDRESS(
ROW(<range here>)+ROWS(<range here>)-1,
COLUMN(<range here>)+COLUMNS(<range here>)-1
)
)
This would give you the start of the range as a string:
=cell("Address",OFFSET(INDIRECT(PayStaff),0,10))
The end of the range is more awkward - you would have to add the number of rows in the range (-1) to the row offset:
=cell("Address",OFFSET(INDIRECT(PayStaff),rows(indirect(PayStaff))-1,10))
I have a 5x5 grid of tiles that are number like:
Numerical order Row number(eg: 1 1 would be the first tile on the first row and 6 2 would be the first tile on the second row)
I need to get the blocks around a clicked tile (above, below, left and right), I thought about doing this by taking off numbers from the numerical order and row number. I wrote this:
local ab = tostring(tonumber(v.Name)-5)..tostring(tonumber(string.sub(v.Name,-1))-1)
local be = tostring(tonumber(v.Name)+5)..tostring(tonumber(string.sub(v.Name,-1))+1)
ab being the tile above and be being the tile below. I ran into a problem where I cannot get the first two letters of a tile who's numerical order is two digits using one line (I don't want to use if statements since I'm pretty sure there's a one line solution)
I came up with a solution and that is to get all the characters before the whitespace (which separates the order from the row number) but I have no idea how to write it.
Just ask for all non-whitespace characters from the beginning of the string:
print(("test123 more456"):match("^(%S+)"))
This should print test123.
This question already has answers here:
Closed 11 years ago.
Possible Duplicate:
cobol difference with Picture having a dash (-) and a having a X
I'm tying to get to grips with Cobol and can't understand the dashes when formatting a number. I have this example:
--9
Am I correct with the following?
The first dash - If number is a negative put a dash otherwise don't.
the second dash - I'm confused with this. There is already a dash at the start to specify whether its negative or positive.
9 - Numeric digit (0-9)
An example would be good. :S
Thanks
In view of your previous question, Im not sure what you are having trouble with. But lets try again...
In COBOL, numeric display fields may contain various types of "punctuation". This "punctuation" is defined in the items PICTURE clause. A few examples of the type of "punctuation" symbols you can use are: Explicit decimal points, plus/minus signs, CR/DR indicators and thousnads separators (commas in North America). There is a well defined set of rules that determine what type of "punctuation" can occur in the PICTURE clause and where. This link to PICTURE CLAUSE editing explains how to construct (or read) any given PICTURE clause.
One thing that you, and many others new to COBOL, trip up on is that a data definition in COBOL specifies two distinctly different types of information about numeric display data. One is the range of values it may hold and the other is how
that range of values may be displayed. Your example: PICTURE --9 tells me two things about the data item: 1) Values are integers in the range of -99 through to +99, and 2) Displaying this item will take 3 spaces. If the number is positive, spaces will appear before the first non zero digit. If the number is negative a minus sign will appear immediately to the left of the first non zero digit. Consider the following COBOL DISPLAY statement:
DISPLAY '>' DISP-NBR '<'
IF DISP-NBR has a PICTURE clause of: --9 this is how various values will be displayed.
0 displays as: > 0<
-1 displays as: > -1<
-11 displays as: >-11<
10 displays as: > 10<
Note that all displays take 3 character positions. At least 1 digit will always be displayed (because of the '9' in the PICTURE clause), other than that, no leading zeros are displayed. A minus sign will display only for negative values. The minus sign, if displayed will be to the immediate left of the first displayed digit.
Now to answer you specific question: The total number of character positions needed to display a numeric display data item is determined by the length of the PICTURE. You have a 3 character PICTURE so 3 character positions are needed. When
a sign is specified in the PICTURE, a space is always reserved for it. This is what limits the range of integers to those containing at most 2 digits. The second minus sign indicates 'zero supression'. Zero supression just means not printing leading zeros. Only 1 minus sign is ever printed and it will be to the immediate left of the first displayed digit.
COBOL contains a lot of flexability with respect to displaying numbers. Understanding the numeric display PICTURE clause is key to understanding how this all works.
from stackoverflow:cobol-difference-with-picture-having-a-dash-and-a-having-a-x
The dash means that if you have a negative number, a dash will be
shown beside (at the left) of the number. Only one dash will be
displayed. If the number is positive, a space will shown for every
dashes.