Solved

remove first 3 lines of a string

Posted on 2013-11-07
10
227 Views
Last Modified: 2013-11-07
I have a textbox listed below and would like to know how to remove the first couple of line.  I would like my textbox to start with the line "insert_job"


 
 /ASYS /backup /bin /boot /CC /dev /etc /export /home /lib /lib64 /lost+found /media /misc /mnt /net /opt /oracle /proc /PSL_install.log /root /sbin /selinux /srv /sys /tmp /usr /var ----------------- chadster ----------------- */
 
 insert_job: chadster job_type: c
 command: sleep 2
 machine: server2
 owner: userid
 permission: gx
 description: "clone test job"
 std_out_file: /tmp/chadster.out
 std_err_file: /tmp/chadster.err
 alarm_if_fail: 0
0
Comment
Question by:chadmanvb
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 6
  • 3
10 Comments
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630239
is it always that sequence character for character before
Insert Job ?
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630245
also is the output of the textbox a string ?
0
 

Author Comment

by:chadmanvb
ID: 39630261
No, the text before "insert" does change everytime and I am useing a string for the textbox.
0
Industry Leaders: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 
LVL 22

Expert Comment

by:plusone3055
ID: 39630325
okay then there are 2 steps to this

1. you need to do an indexof the string that is the textbox looking for
insert_job:

intposition = strtextbox.Indexof("insert_Job",0)

2. use RIGHt to display everything to the RIGHT of that inpostion from the string

dim strtexboxoutput as string = RIGHT(strtextbox,inposition)


that should do the trick
0
 

Author Comment

by:chadmanvb
ID: 39630507
What am I doing wrong?  It have -1 for my intposition and that does not seem correct.  Also I cant compile with inposition on the last line.

Here is what I have

 Dim intposition
        Dim strtextbox As String = TextBox1.Text

        intposition = strtextbox.IndexOf("insert_Job", 0)
        MsgBox(intposition)

        Dim strtexboxoutput As String = Strings.Right(strtextbox, inposition)
0
 
LVL 22

Accepted Solution

by:
plusone3055 earned 500 total points
ID: 39630575
this works

       Dim str123 As String
        str123 = txt1.Text
        MessageBox.Show(str123)

        Dim intposition As Integer
        intposition = str123.IndexOf("insert", 0)
        MessageBox.Show(intposition)

        Dim stroutput As String = str123.Substring(intposition)

        MessageBox.Show(stroutput)
0
 

Author Closing Comment

by:chadmanvb
ID: 39630602
Pefect!  Thanks!
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630614
no problem happy coding :)
0
 
LVL 40
ID: 39630619
Take the time to define the type of your variables. It prevents many types of bugs:

Dim intposition as Integer.

IndexOf is sensitive to case. According to your original question, you should look for insert_job with a lowercase 'j'.

The last line does not work because you forgot the 't' in the third character of intposition.
0
 
LVL 22

Expert Comment

by:plusone3055
ID: 39630633
JamesBurger is right
I didnt even see the syntax errors on that when you posted until he pointed them out. Slow and steady does win the race :)
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I think the Typed DataTable and Typed DataSet are very good options when working with data, but I don't like auto-generated code. First, I create an Abstract Class for my DataTables Common Code.  This class Inherits from DataTable. Also, it can …
The ECB site provides FX rates for major currencies since its inception in 1999 in the form of an XML feed. The files have the following format (reducted for brevity) (CODE) There are three files available HERE (http://www.ecb.europa.eu/stats/exch…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Attackers love to prey on accounts that have privileges. Reducing privileged accounts and protecting privileged accounts therefore is paramount. Users, groups, and service accounts need to be protected to help protect the entire Active Directory …

739 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question