# Regular Expressions - Using output?

**URL:** <https://forum.kirupa.com/t/regular-expressions-using-output/276784>\
**Category:** flash\
**Created:** [December 3, 2008, 4:49pm UTC](https://forum.kirupa.com/t/regular-expressions-using-output/276784 "2008-12-03T16:49:41Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![energy](https://avatars.discourse-cdn.com/v4/letter/e/f1d935/32.png) [@energy](https://forum.kirupa.com/u/energy)\
**Post date:** [December 3, 2008, 4:49pm UTC](https://forum.kirupa.com/t/regular-expressions-using-output/276784/1 "2008-12-03T16:49:41Z")

</div>

Hey Guys,

I am trying to add “Newline” before and after beginning of every lesson.  
Suppose Input is  
[AS]var str:String = “Lesson 1 Jobmatching.” + "  
" + “This is Job Matching Lesson text” + "  
"+ “Do you know this.” + "  
" +“Lesson 2 Basics of FlashDesign.” + "  
" + “This is Basics of Flash Design Lesson Text”;  
[/AS]  
Now when you trace str, it will be this.

```auto
Lesson 1 Jobmatching.
This is Job Matching Lesson text
Do you know this.
Lesson 2 Basics of FlashDesign.
This is Basics of Flash Design Lesson Text

```

So i have already written a regular expression which matches this text  
[AS]var pattern:RegExp = /Lesson+ ([0-9]+) ([a-z]+)\*./[/AS]  
Looks Correct…isn’t it.  
Now I have tried “str.replace”…“str.match” etc but couldn’t get the desired output.  
This is the output i am looking for:

```auto
Lesson 1 Jobmatching.

This is Job Matching Lesson text
Do you know this.

Lesson 2 Basics of FlashDesign.

This is Basics of Flash Design Lesson Text

```

So how can i achieve this.Any thoughts?  
Thanks.
