Substring in flex3 - actionscript-3

I want to use substring in flex side like eg:- m having sm no like 0001A,0287393A,22839A,etc
i need to use substring for numeric only and chop character value. Or else if you have sm other idea beside using substring can share much appreciated

I think I understand the question. You want to convert the numeric part of the string to a Number, and drop the characters. If so, you're in luck:
http://help.adobe.com/en_US/FlashPlatform/reference/actionscript/3/package.html#parseInt()
parseInt('0001a') should return Number(1).

Related

Match specific string before user input

I have the following strings:
SDZ420-1241242,
AS42-9639263,
SPF3-2352353
I want to "escape" the SDZ420- part while searching and only search using the last digits, so far I've tried RLIKE '^[a-zA-Z\d-]' which works but I am confused on how to add the next digits (user input, say 1241242) to it. I cannot use LIKE '%$input' since that would return a row even if I just input '242' as the search string.
In simple words, a user input of '1241242' should return the row with 'SDZ420-1241242'. Is there any other approach other than creating a separate table with the numbers only?
Note that without jumping through some crazy hoops, this search needs to hit every row in the table; if you have an index on this, it's not going to use that (an index is generally used, assuming it's of the proper kind, which they tend to be, when you search on start, and generally only when using LIKE 'needle%' and not RLIKE. If that's a problem, storing the digits separately, and then putting an index on that, is probably the simplest way to solve your problem here.
To query for the final few digits, why not:
SELECT * FROM foo WHERE colName LIKE ?
with the string made in your programming language via:
String searchTerm = "%-" + digits;
You can also pass in the number as a string and use:
where substring_index(colname, '-', -1) = ?
This does not require changing the value in the application code.

Format Function returns wrong value

We have a field in a query that should be left-padded with zeroes if it is too short, and we accomplish this using the Format() function. However, there are some values that produce bizarre results.
Format("14425112-8","00000000-00")
Returns the value "00019330-78"
For most inputs, the string gets formatted as expected, 8 digits, hyphen, two digits. But in a few rare cases, the value is modified. Is this repeatable for anyone else? Does anyone have an explanation?
Thanks for your help.
This is an example of access trying to be too helpful. It looks like it is interpreting these values as dates, but since you didn't use any date indicators in the format e.g: (dd,mm,yyyy), it converted 1-1 to a date, and then tried to display it in decimal form:
debug.print Format("1-1","000000-00")
returns 000427-36 which is the decimal value 42736 which, if you convert to a date, becomes 1/1/2017. This is what access interpreted "1-1" as.
it seems that access has reserved the - character as symbolizing a date format, despite what their website says. This function is only useful for formatting actual dates, or numeric values, such as prices. If you are set on using the format function, you will have to change you separator to a decimal point, which apparently is the only character that will get you what you want with the leading and trailing zeros.
Otherwise, you may have to build your own function for this.
You cannot format a string like a number this way. Try this:
PaddedNumber = Right(String(8, "0") & "14425112-8", 10)

Locate, Substring query

I am trying to pull the data from between 2 string points in mysql, my example script would be
'otherdata&p1=textneeded&otherdata'
I need to pull the "textneeded" bit, "P1=" is the start position and will only appear once within the string but the "&" sign can appear multiples times. If there is nothing between these 2 points just return a blank. Where I have put otherdata, this can be a varying number of things on either end of the points I am trying to extract the data from. I am no expert at all on mysql so any help would be appreciated.
Thanks
You may use MySQL's locate() function to get the position of p1= substring and then the position of the next & and use substr() to extract the string between the two. +3 and -3 are to compensate for the length of p1=:
set #s='otherdata&p1=textneeded&otherdata';
select substr(#s,locate('p1=',#s)+3,locate('&',#s,locate('p1=',#s))-locate('p1=',#s)-3)

Using mysql how to find 1st occurrence of a alphabet in a string

Using mysql I need to find the position of the 1st occurrence of any alphabet in a sub string.
For example if my string is like 123456A12345 then I need to find the position of A.
My main goal is to get all the digits just before the alphabet.
Thanks in advance.
If you want to get all the digits, just convert the string to an integer by adding 0:
select '12345abc'+0
returns 12345.
This does not handle leading 0s. And, it won't work for any length expression, but it may solve your problem quickly.

MySQL REGEXP matching positive numbers

I have a column varchar[25] with this data inside :
886,-886
-886
0,-1234
1234
(empty)
0
the numbers might change in size from a 1 digit to a n digits.
and I need to be able to pull any row that has at least one positive number in it
I was thinking that something like
REGEXP '[^-,][0-9]+'
but this pulls -886 as 88 matches the regexp
you probably does not require regex
COL not like '-%' AND COL not like '%,-%'
however, this is the bad example of storing into incorrect data type,
split , and store into multiple rows ...and you can save some time for handling something like this question
Try using this :
"[^-\d]\d+\b"
which should work if i understood your question correctly.
a good regex reference table : http://www.regular-expressions.info/reference.html
I was able to figure out the best solution:
`COL` NOT LIKE '%-%'
I forgot to mention that the column might also contain words like:
all,-886
none,886
0,1,2,3,none
0
etc...
Try
REGEXP '[[:<:]][^-,][0-9]+[[:>:]]'
The :<: and :>: portions indicate word boundaries.
^\b\d+\b$
will give you positive integers.
^[^-]\d+((,([^-]\d+))?)+$
will give you only the lists where all the values are positive integers
For a list with any positive integer (but all valid integers negative or positive) I thinks this will check out:
^((-\d+,)?)+[^-]\d+((,([^-]\d+))?|(,-\d+)?)+$
Here's a great site for Regular Expressions:
http://gskinner.com/RegExr/
I use it all the time for testing live.