regular expression in asp.net [closed] - asp.net

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
in my application i have a text box in that '123456789v' first 9 charecter must be digits after that any character or a particular character how can i write please help me. thank u

If the last character must be a alphabet:
^[0-9]{9}[a-zA-Z]$
If the last character can be anything other than a number
^[0-9]{9}[^0-9]$

How about: \d{9}.
Edit: Explained the regex:
\d = Any digit
{9} = 9 times
. = Any character

Somthing like:
[0-9]{9}.
Or if the last character must be an alpha character:
[0-9]{9}[a-z]
If you are new to regular expression I sujest you get your hands on a tool to help you with them. I personaly like this Expresso: http://www.ultrapico.com/Expresso.htm but you can also google for a "regex designer" as there a number of good ones online.

I'd say
^\d{9}[A-Za-z]$
To match 9 digits and one alphabetic character, and nothing before or after.

Regex r = new Regex("[0-9]{9}[a-zA-Z]$");
label1.Text = r.IsMatch(textBox1.Text).ToString();
If specific character then:
[0-9]{9}v$

Perhaps something like this may help.
^[0-9]{9}.
EDIT: Removed escape characters.

Related

Action Script 3.0 substring, slice, split, substr [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
i want to get the value in between - and - how?
Private var Test:String = "1-ALOW-The One Who Loves You Now";
Output should be = ALOW
test = test.split("-")[1];
trace(test) // output: ALOW
You can use the following code:
Private var test:String = "1-ALOW-The One Who Loves You Now";
var my_array:Array = test.split("-");
test = my_array[0]+"_"+my_array[1]+"-"+my_array[2];
using split you get the string splitted on "-" into an array; then and concatenate the single parts in the final variable

Getting special character in FastExport script [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 9 years ago.
sel cast(trim(Env) as char(6)) ,
cast (trim(Databasename) as char(30)) from DB.Top_Space_Consumer;
I am running above query through fast export and getting data in below format.
%^#^#PKPTD DB1
%^#^#PKPTD DB2
%^#^#CLPTD DB3
%^#^#PKPTD DB4
i want data in below format.
PKPTD DB1
PKPTD DB2
CLPTD DB3
PKPTD DB4
As the size of the table is "big" a few Gigabytes, i can't open it with a text editor in order to remove the characters.
The question is:
What should i change in the script in order not to obtain this "extra characters"?
I am guessing your export format is FASTLOAD or BINARY. FastExport appends two binary bytes of data to the beginning of each record.
To get around this in the past I have concatenated the fields together with the delimiter of choice and casted the datatypes to a character and then casted the record to a fixed length. This does mean there is trailing white space at the end but that can be easily accounted for when loading the data into the next environment. Then you can change your export format to TEXT and the binary data will not be appended to the beginning of your records.

Apply a function on columns of a matrix [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
I'm using a function ("myfunction") from an R library in this way:
myfunction(obj1, obj2, obj3, c("Name1", "Name2"))
where "Name1" and "Name2" are two gene names. Instead of retrieving information about this two genes, I would like to retrieve information on many other genes that are stored in a file with 1000 columns and 100 rows (100 rows are 100 gene names).
In other words, suppose my file is named fl1000. For each column I would like the following code:
myfunction(obj1, obj2, obj3, fl1000[,1])
myfunction(obj1, obj2, obj3, fl1000[,2])
myfunction(obj1, obj2, obj3, fl1000[,3])
....
myfunction(obj1, obj2, obj3, fl1000[,1000])
Since it is impossible to do so manually, how this can be done in a more compact and fast way?
Your function has four arguments - obj1, obj2, obj3, and an unnamed argument that seems to be vector of two names. It's not clear what those first three objs are - they vectors, single elements, or what?
So the first problem seems to be in what way could you possibly run a function of this sort on a single column from your rectangle of data. To get anything working with apply on that rectangle, you will need a function that takes as its input a single vector of 100 elements. Clearyl myfunction() is not such a function as it currently stands. However, if that vector can be fed in as eg obj1, and you just need to supply other things to be obj2 and obj3, it would be simple to adjust the function so it will work. But unless we have more of an idea of what you are doing we couldn't help more.
Edit (after question's edit)
The question still doesn't quite make sense to me, as the function looks like it wants a vector of Name1 and Name2, and you now want to give it a row with 100 values (not just 2).
But putting that aside, perhaps you want:
apply(fl1000, 2, function(x){myfunction(obj1, obj2, obj3, x)})

write method in R -where does the file end up? [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
It seems forloops in R do not work exactly the way I thought:
myVector <-c(0,0,0)
> for (i in 0:0){
s1<-sum(e1*data3[,i]);
s2<-sum(e2*data3[,i]);
s3<-sum(e3*data3[,i]);
hilf <- cbind(s1,s2,s3);
myVector <- cbind(myVector, help);
}
works but the result is:
> myVector
myVector s1 s2 s3
[1,] 0 0 0 0
now, I would expect something like 3 zeros.
Does anyone know why I get four dimensions instead of three?
Despite the fact that the code you posted is, eh, interesting, what is happening here has nothing to do with for-loops. It is your multiple cbind statements.
you are attempting to combine a tall 1x3 matrix with a vector of length 3. This will cause myVector to lose it's last two elements when combined, as you witness in the output you have pasted.
instead, if you transpose one of the two (either myVector or hilf) you might get something more in line with what you are looking for.
I am assuming that by help you meant hilf.

Correct the format of my function output [closed]

It's difficult to tell what is being asked here. This question is ambiguous, vague, incomplete, overly broad, or rhetorical and cannot be reasonably answered in its current form. For help clarifying this question so that it can be reopened, visit the help center.
Closed 10 years ago.
Here is my function to calculate beta for the China stock market:
mybeta <- function(company) {
require(quantmod)
setSymbolLookup(CSI300=list(name="000300.ss",src="yahoo"))
getSymbols("CSI300",from="2010-01-01",to="2011-01-01")
setSymbolLookup(SDB=list(name=company,src="yahoo"))
getSymbols("SDB",from="2010-01-01",to="2011-01-01")
csi=as.data.frame(weeklyReturn(CSI300))
sdb=as.data.frame(weeklyReturn(SDB))
cbeta=merge(csi, sdb, by="row.names")
cov(cbeta[2],cbeta[3])/var(cbeta[2])
}
when i input:
mybeta("600005.ss")
weekly.returns.y
weekly.returns.x 1.105631
I only want the 1.105631 from the output, not the "weekly.returns.y" and "weekly.returns.x". How can I do that?
It's clear English isn't your first language, so I will be patient.
You have revealed what you are actually trying to do, so your first two questions (one, two) could have been avoided because they are not useful for solving your actual problem.
Here is a modified version of your function that accomplishes the same goal, with a lot less unnecessary work.
mybeta <- function(company) {
if(!require(quantmod))
stop("quantmod must be installed; try install.packages('quantmod')")
setSymbolLookup(CSI300=list(name="000300.ss",src="yahoo"),
SDB=list(name=company,src="yahoo"))
getSymbols(c("CSI300","SDB"),from="2010-01-01",to="2011-01-01")
ret <- merge(weeklyReturn(CSI300),weeklyReturn(SDB))
cbeta <- cov(ret, use="pairwise.complete.obs")
cbeta[1,2]/cbeta[1,1]
}
Use as.numeric
Make the last line of your function
as.numeric(cov(cbeta[2],cbeta[3])/var(cbeta[2]))
As an aside, there is no reason to be using data.frames here. xts is awesome; embrace it.
Edit:
In addition to not needing to convert to data.frame, it's probably safer for your function to not have side-effects (for example, getSymbols("SDB") would return a different value depending on what you passed to mybeta last; also, getSymbols assigns data in your .GlobalEnv by default. You might consider using auto.assign=FALSE. This is how I would edit your function:
mybeta <- function(company) {
require("quantmod")
CSI300 <- getSymbols("000300.ss", src='yahoo', from="2010-01-01",
to="2011-01-01", auto.assign=FALSE)
SDB <- getSymbols(company, src='yahoo', from="2010-01-01", to="2011-01-01",
auto.assign=FALSE)
csi <- weeklyReturn(CSI300)
sdb <- weeklyReturn(SDB)
cbeta=merge(csi, sdb)
as.numeric(cov(cbeta[, 1], cbeta[, 2])/var(cbeta[, 1]))
}

Resources