Get line x from string
I need to do the following type structure on a string in
Flash where tSTNames is a string
This is typical director Lingo i would use to do this.
repeat with i = 1 to tStNames.line.count
tName = tStNames.line
--stuff
end repeat
I know this will need to be a for loop of some kind but I
don't see any easy way to get a line count or to extract a line of
text at a time from the string.
I keep hearing how wonderful Flash is -- but here's a simple
string parsing need and it sure doesn't look easy.
Must be missing something.
Thanks
You might want to take a litle peek at the String object.
var s = "line 1\nline 2\nline 3\nline 4"
var lines:Array = s.split("\n");
trace("There are " + lines.length + " lines in: \n" + s);
trace("");
for(var i=0; i<lines.length; i++){
trace("line "+i+" is " + lines
Similar Messages
-
How can I get some text from string like AB_CD_9.9.9_Sometext
How Can I get
only 9.9.9 from string "AB_CD_9.9.9_Sometext" with powershell and regular expression?
Thank you,
LeiThis works.
if('AB_CD_9.9.9_Sometext' -match '\d\.\d\.\d'){$matches[0]}else{'notfound'}
¯\_(ツ)_/¯ -
How do I get line preview from Source monitor using Axio?
Any ideas on how I get a line preview from the source monitor on my Axio (the "full blwn" Axio, not the LE)
In CS4, go to Edit > Preferences > Player Settings, and in the Default Player drop-down, choose the Matrox player.
-
Getting Color object from String
hi
i need to get a Color object from a string provided at runtime.ie for the string "RED" i need to get a object of Color.RED.I have already tried to use decode() from Color class but it throws numberformat exception,can someone guide me.Color.decode(String) will decode octal and hexidecimal representations of colors e.g.
Color poo = Color.decode("0x215DB8"); // hex description of color
works.
If you want to use RED, BLUE ... read them at run into a String or whatever and then test this String to get what color the user wanted e.g.
read from text file at run time that button colour should be ORANGE.
In your code, put
String colourStr; // read what colour the user specified into this var
Color their_color = null;
if(colour.equals("ORANGE"))
their_color = new Color(Color.orange);
else if(colour.equals("BLACK"))
// you can guess what goes here.. and so on.
It often nice to make them specify the hex value of the colour because there are more of these than the predefined colours (shock horror).
Anyway,
seeya, Edd. -
How to get URL type from String.
Hi,
Is there any way to convert a String or String to int to URL type? For example, I getting value form a JTextArea. This value will be a int ( A combination of number only) so I am converting the String the int and then can it be converted into URL???
Thanksmerit wrote:
I tried reading it but I dont understand the syntax. Can you please show me how to do this?
public uRLReader(String uRL)throws MalformedURLException{
URL newURL = new URL(uRL);
retrun (newURL);
}will this code convert the String to URL type?
Thank you.What don't you understand? If you don't know how to use the API docs to use a class, then you need to start from the very beginning of a Java tutorial.
Also, you have what looks like a constructor, but it's returning a value. C'tors don't return values at all, and the value you're trying to return is a URL, which means you'd have to declare this as a method that returns URL.
You seem to be struggling with basic, fundamental concepts. I recommend you get a better handle on those before trying to do anything with URLs.
[http://java.sun.com/docs/books/tutorial/] -
Regular expression - get longest number from string
I believe it is easy one but I can't get it.Lets say I have a string 'A1_1000' I want to substract the 1000 using regular expression. When I feed Match regular expression I get '1' which is not the longest number. I know other ways of doing that but I want clean solution in one step. Does anybody knows the right regular expression to accomplish that? Thanks!
LV 2011, Win7
Solved!
Go to Solution.ceties wrote:
This is the best solution I was able to come with. I am just wondering if there is "smoother way" without the cycle.
Since multiple checks are required I would tend to beieve that we do have to loop through the possibilities. in this example
I start check at offset "0" into the string for a number. Provided i find a number I check if it is longer that any previous number I found and if so save the new longer number in the shift register.
Have fun!
Ben
Message Edited by Ben on 04-15-2009 09:23 AM
Ben Rayner
I am currently active on.. MainStream Preppers
Rayner's Ridge is under construction
Attachments:
Find_Longest.PNG 33 KB -
How to get line error from a procedure?
Hello,
I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
How to do it?
Thanks in advance.
EXCEPTION WHEN OTHERS THEN
HTP.P('Sorry');
emailme(SQLERRM);
emailme(line where erro occurs);???????
END;
null<BLOCKQUOTE><font size="1" face="Verdana, Arial">quote:</font><HR>Originally posted by Paula Bronfman ([email protected]):
Hello,
I want to know the line where the error occurs, since when I treat the exception to show a user friendly error page this erro is not logged at OAS.
How to do it?
Thanks in advance.
EXCEPTION WHEN OTHERS THEN
HTP.P('Sorry');
emailme(SQLERRM);
emailme(line where erro occurs);???????
END;
<HR></BLOCKQUOTE>
Hi;
your best bet would be to set a variable in the procedure every 10 lines or so, and email the contents of that var.
begin
mydebug:=0;
mydebug:=10;
when others then
emailme(SQLERRM| |' '| |mydebug);
end;
Cheers
Paulo -
How to get Line number from a DOM Element
Hi
I am using dom xerces parser. Is there anyway to work out which line number a element will be when it is outputted into a file ??org.w3c.dom.DOMLocator method getLineNumber() returns the line number at which an error occurs.
A corrresponding method for file output is not defined. -
Way to get line count from text areas?
the getLineCount method on JTextArea only returns the number of linebreak characters in the stream, but I am looking to get the number of rows the text is taking in the text area. When you have word wrap activated, and the text wraps around, no linebreak is inserted so the getLineCount method will return a wrong number. anyway to get around this?
http://forum.java.sun.com/thread.jsp?forum=57&thread=122550
-
How to get InputStream from String ?
Hi !
I want to get InputStream object from String.
String str = "balabalabala";
InputStream stream = getInputStream(str);
How to realize getInputStream(str) function ?
Thanks!The preferred method nowadays is to use Readers and Writers for String data - hence StringReader(String). If you're going to operate on the InputStream directly, then I'd modify your code to use the Reader calls and go that route.
If, however, you need to pass the InputStream to some other piece of API that requires an InputStream instead of a Reader, then the ByteArrayInputStream is probably your best bet. StringBufferInputStream is deprecated because it doesn't work reliably in the face of many character encodings.
Speaking of encodings - never call Strng.getBytes() - always use the getBytes(character-encoding) version, so you KNOW what encoding you're getting!
Grant -
How to remove end of line from string?
Hello,
I'd like to remove ends of line from the string. I've tried:
static final Pattern END_LINE_PATTERN = Pattern.compile("$+");
strBuf.append(input);
Matcher m = END_LINE_PATTERN.matcher(input);
int startIndex = -1;
int endIndex;
while (m.find()) {
startIndex = m.start();
endIndex = m.end();
if (endIndex == strBuf.length() - 1) break;
if (startIndex > -1) {
strBuf.setLength(startIndex);
}For strings "hello\n" and "hello\r" it works properly, but for string "hello\n\n" I get first occurrence at index 6 (at second \n), so as the result I get "hello\n". For the string "hello\r\n" I get first occurrence at index 5 (it's OK), but the end index is 5 as well, and the next occurrence I get at index 7, which doesn't give me any sense.
Hope somebody can help me.
AgataWhat you're trying to do is remove one or more line separators from the end of a string ("\n", "\r", and "\r\n" each count as one line separator, but "\n\n" is two line separators). This is all you need to do: str = str.replaceAll("[\r\n]+$", ""); "$" doesn't match any characters, line separators or otherwise; it matches the position at the end of the string. In MULTILINE mode, it also matches the position before a line separator, but it still doesn't match the separator itself.
-
How can we get the selected line number from JTextArea ?
how can we get the selected line number from JTextArea ? and want to insert line/string given line number into JTextArea??? is it possible ?
Praitheesh wrote:
how can we get the selected line number from JTextArea ?
textArea.getLineOfOffset(textArea.getCaretPosition());
and want to insert line/string given line number into JTextArea??? is it possible ?
int lineToInsertAt = 5; // Whatever you want.
int offs = textArea.getLineStartOffset(lineToInsertAt);
textArea.insert("Text to insert", offs); -
How to use a regural expression to get all digit from a string.
Hi All,
Do you know how to use regural expression to get all digits from the following string via ABAP program?
"'Log Attributes 0 ( 0 ) ( 10 % Available )"
Thanks,
AndrewHi,
Try the code mentioned below:
DATA: STR_LEN LIKE SY-FDPOS,
RSTR_LEN LIKE SY-FDPOS,
OFF LIKE SY-FDPOS.
DATA: IDX LIKE SY-FDPOS, "mn B20K054003
CL LIKE SY-FDPOS. "mn B20K054003
DATA: RSTRING(40).
DATA: STRING(40). " value 'A,N,I,L'.
FIELD-SYMBOLS: <NLS_CHAR>. "mn B20K054003
MOVE I_REGUH-ZNME1 TO STRING.
MOVE SPACE TO RSTRING.
STR_LEN = STRLEN( STRING ).
DESCRIBE FIELD RSTRING LENGTH RSTR_LEN.
IF RSTR_LEN < STR_LEN. RAISE TOO_SMALL. ENDIF.
WHILE IDX < STR_LEN. "mn B20K054003
ASSIGN STRING+IDX(*) TO <NLS_CHAR>. "mn B20K054003
IF SY-LANGU EQ '2'. "mn B20K054003
CALL FUNCTION 'NLS_THAI_CHARLEN' "mn B20K054003
EXPORTING "mn B20K054003
THAI_STRING = <NLS_CHAR> "mn B20K054003
CHANGING "mn B20K054003
THAI_CHARLEN = CL. "mn B20K054003
ELSE. "mn B20K054003
CL = CHARLEN( <NLS_CHAR> ). "mn B20K054003
ENDIF. "mn B20K054003
IF IDX NE 0. "mn B20K054003
SHIFT RSTRING RIGHT BY CL PLACES."mn B20K054003
ENDIF. "mn B20K054003
RSTRING+0(CL) = STRING+IDX(CL). "mn B20K054003
IDX = IDX + CL. "mn B20K054003
ENDWHILE. "mn B20K054003
Regds,
Anil
Edited by: Matt on Jul 1, 2009 9:36 AM -added code tags -
Get distinct values from a coma seperated string variable
Hi ,
I am getting an comma seperated string as in parameter, now i want to get the distinct values from that string and will use those values to pass it to a query.
any helptry this:
sorry about the messiness - it's just quickly copied from some badly formatted code....
TYPE T_FieldArray IS TABLE OF varchar2(255) INDEX BY BINARY_INTEGER;
function SPLIT_CSV_FIELDS (
p_Input_Str in varchar2,
p_Delimiter in varchar2,
p_Quote_Char in varchar2)
return t_fieldarray is
v_FieldArray T_FieldArray;
v_input_str varchar2(4000);
v_field_str varchar2(255);
v_pos number;
e number := 0;
v_delim_str varchar2(3);
cur_pos number;
begin
loop
-- find each delimiter char in string
v_pos := INSTR(v_input_str, p_Delimiter);
-- each time delimiter char is found
if v_pos > 0 then
-- current field value is current string to position prior to delimiter char
v_field_str := UPPER(SUBSTR(v_input_str, 1, v_pos - 1));
-- remove quote char from end of field (if any)
v_field_str := TRIM(TRANSLATE(v_field_str, NVL(p_Quote_Char, p_Delimiter), ' '));
-- increment element number
e := e + 1;
-- get remainder of input string to check
v_input_str := SUBSTR(v_input_str, v_pos + 1, LENGTH(v_input_str) - v_pos);
v_FieldArray(e) := v_field_str;
else
-- increment element number
e := e + 1;
-- last field value is what's left of input string less quote char (if any)
v_field_str := TRIM(TRANSLATE(UPPER(v_input_str), NVL(p_Quote_Char, p_Delimiter), ' '));
v_FieldArray(e) := v_field_str;
exit;
end if;
end loop;
return v_FieldArray;
end; -
How to get int value from [session.getAttribute("String")]
i am not able to get int value from the following statiment
int i=session.getAttribute("String");
i also try by casting it into int but it dont work, can somebody help me in this regardabuu wrote:
i am not able to get int value from the following statiment
int i=session.getAttribute("String");
i also try by casting it into int but it dont work, can somebody help me in this regard
Integer i=(Integer)session.getAttribute("String");
i.intValue();but know how it is working. that is useful.
Diablo.
Maybe you are looking for
-
Hi, I am into the preparation of Production server (in High Availability environment) installation on HP UX server. We have developement server running on one server and Production server on another server. I have to cluster the production server wit
-
Computer Icon not appearing as it should
I was looking at forms to see if I could get 10.5 to see that I am using a Black MB not a White one. I was wondering if there is any way to change this. I have tried renaming the file and placing in a new icon. It now show that I am running an old im
-
N73 with Navicore needs firmware version 2.0628.0....
Hi folks, I have N73 with v0.0.1 firmware but have been told by Navicore that I need 0.0.3 to run their Personal Europe 2006/1 software. Problem is if you go the Nokia site there is no Firmware upgrade for the N73 handset. Anyone got any idea how to
-
Why does logic randomly delete my project files?
Logic will periodically delete the project files from the project folder and i can't get it to stop. It often costs me hours of work. For example, i'll close logic (and save) and come back the next day to find the "xxxx.logic" file missing. No alias,
-
iphoto 9.5 won't import photos from iPhoto 7.5. Library will not update using the iPhoto library upgrader application. Repeatedly says it can't locate photos even when told to cancel. I think the photos in question are in Nikon RAW format.