Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- ## Use your own syntax in strings to create complex logic
- #set($myString="Arts course: ^^ARTS-2113^^, Biology course: ^^BIOL-1244^^")
- <p>
- <h2>Starting string</h2>
- $myString
- </p>
- <p>
- <h2>Simple regex replace:</h2>
- $myString.replaceAll("\^\^([A-Z]{4})-?([0-9]{4})\^\^","$2 $1")
- </p>
- <p>
- <h2>Use sections of string to perform pulls</h2>
- #set($stringPieces = $myString.split("\^\^"))
- #set($stringPieceCount = 0)
- #foreach($stringPiece in $stringPieces)
- #if($stringPiece.matches("([A-Z]{4})-?([0-9]{4})"))
- #set($startLetters = $stringPiece.substring(0,3))
- #foreach($story in $dotcontent.pull("+structureName:OcNews +OcNews.title:${startLetters}*",1,"modDate desc"))
- $story.title
- #end
- #else
- $stringPiece
- #end
- #set($stringPieceCount = $stringPieceCount + 1)
- #end
- </p>
Advertisement
Add Comment
Please, Sign In to add comment