The textfile contains text like this
[Event "?"]
[Result "*"]
[SetUp "1"]
[FEN "4b3/pq2p1k1/1p1pP2R/1P1P2K1/2rp4/8/P5Q1/8 w - - 0 50"]
[PlyCount "0"]
*
[Event "?"]
[Round "39"]
[Result "*"]
[SetUp "1"]
[FEN "5rk1/5p1p/3q2p1/1Rp1n3/P3P3/3Pb1pP/2Q3B1/3R3K b - - 0 1"]
I want to change [Event "?"] to [Event "Black to move"] if in the line [FEN .... ] I find a space, then b followed by another space
and to change it to [Event "White to move"] if in the line [FEN .... ] I find a space, then w followed by another space
I have tried to use lookahead, but as have not programmed anything in Perl for quite a while with no success.
Sorry for beeing unclear
2017-11-07 Athanasius added code tags
-
Are you posting in the right place? Check out Where do I post X? to know for sure.
-
Posts may use any of the Perl Monks Approved HTML tags. Currently these include the following:
<code> <a> <b> <big>
<blockquote> <br /> <dd>
<dl> <dt> <em> <font>
<h1> <h2> <h3> <h4>
<h5> <h6> <hr /> <i>
<li> <nbsp> <ol> <p>
<small> <strike> <strong>
<sub> <sup> <table>
<td> <th> <tr> <tt>
<u> <ul>
-
Snippets of code should be wrapped in
<code> tags not
<pre> tags. In fact, <pre>
tags should generally be avoided. If they must
be used, extreme care should be
taken to ensure that their contents do not
have long lines (<70 chars), in order to prevent
horizontal scrolling (and possible janitor
intervention).
-
Want more info? How to link
or How to display code and escape characters
are good places to start.
|