c# - removing text from richtextbox -
i have richtextbox1 , want remove "user1". below , if sentence starts alter table , consists "user1". best way using c#
my text on richtextbox
drop index xie2tbl_a; drop index xpktbl_a; alter table "course" drop constraint "crse_crse_fk"; alter table "enrollment" drop constraint "enr_stu_fk"; alter table "enrollment" drop constraint "enr_sect_fk"; alter table "enrollment" add constraint "enr_stu_fk" foreign key ("student_id") references "user1"."student"("student_id") enable; alter table "enrollment" add constraint "enr_sect_fk" foreign key ("section_id") references "user1"."section"("section_id") enable; alter table "grade" drop constraint "gr_enr_fk"; alter table "grade" drop constraint "gr_grtw_fk"; alter table "grade" add constraint "gr_enr_fk" foreign key ("student_id","section_id") references "user1"."enrollment"("student_id","section_id") enable; alter table "grade" add constraint "gr_grtw_fk" foreign key ("section_id","grade_type_code") references "user1"."grade_type_weight"("section_id","grade_type_code") enable; alter table "grade_type_weight" drop constraint "grtw_grtyp_fk"; alter table "grade_type_weight" drop constraint "grtw_sect_fk"; alter table "grade_type_weight" add constraint "grtw_grtyp_fk" foreign key ("grade_type_code") references "user1"."grade_type"("grade_type_code") enable; alter table "grade_type_weight" add constraint "grtw_sect_fk" foreign key ("section_id") references "user1"."section"("section_id") enable; alter table "instructor" drop constraint "inst_zip_fk"; alter table "instructor" add constraint "inst_zip_fk" foreign key ("zip") references "user1"."zipcode"("zip") enable; alter table "section" drop constraint "sect_inst_fk";
i want this:
drop index xie2tbl_a; drop index xpktbl_a; alter table "course" drop constraint "crse_crse_fk"; alter table "enrollment" drop constraint "enr_stu_fk"; alter table "enrollment" drop constraint "enr_sect_fk"; alter table "enrollment" add constraint "enr_stu_fk" foreign key ("student_id") references "student"("student_id") enable; alter table "enrollment" add constraint "enr_sect_fk" foreign key ("section_id") references "section"("section_id") enable; alter table "grade" drop constraint "gr_enr_fk"; alter table "grade" drop constraint "gr_grtw_fk"; alter table "grade" add constraint "gr_enr_fk" foreign key ("student_id","section_id") references "enrollment"("student_id","section_id") enable; alter table "grade" add constraint "gr_grtw_fk" foreign key ("section_id","grade_type_code") references "grade_type_weight"("section_id","grade_type_code") enable; alter table "grade_type_weight" drop constraint "grtw_grtyp_fk"; alter table "grade_type_weight" drop constraint "grtw_sect_fk"; alter table "grade_type_weight" add constraint "grtw_grtyp_fk" foreign key ("grade_type_code") references "grade_type"("grade_type_code") enable; alter table "grade_type_weight" add constraint "grtw_sect_fk" foreign key ("section_id") references "section"("section_id") enable; alter table "instructor" drop constraint "inst_zip_fk"; alter table "instructor" add constraint "inst_zip_fk" foreign key ("zip") references "zipcode"("zip") enable; alter table "section" drop constraint "sect_inst_fk";
for richtextbox1.text
don't need check if each line starts alter table
this:
richtextbox1.text = richtextbox1.text.replace("references \"user1\".", "references ");
if want check alter table
, use little of regex
:
regex reg = new regex("(alter table .+ references\\s+)\"user1\"[.](.+)"); richtextbox1.text = reg.replace(richtextbox1.text, "$1$2");
Comments
Post a Comment