Quantcast
Channel: Adobe Community : All Content - FrameMaker Scripting
Viewing all articles
Browse latest Browse all 888

Regex problem

$
0
0

Dear friends,

My project again is stuck in a hopefully trivial problem. Until now I searched for items in doulbe brackets, such as [[Dante, #712]]. But this form is somewaht superficial. When using EndNote or Citavi to insert placeholder citations, the form is with braces: {Dante, #712}.

Why does my regex in GetTempCitations find nothing?

I have tested this with RegexBuddy and in my standard program editor (EditPad Pro), where the items are found.

var txt1 = "Hello fans {Dante, #712} and just {some words} and another one {DuçanÌsídõrâ, #312}.";    GetTempCitations (txt1);

var txt2 =  "introduction to [Content with square brackets] and he rest of something";     otherTest (txt2);

function GetTempCitations (pgfText) {
  var regex = /{([^}]+)}/g;                       // g for global find  while (result = pgfText.match (regex)) {    if (result != null) {      alert (pgfText.match (regex)[1]);     }  }
}

function otherTest (pgfText) {
var regex = /\[([^\]]+)\]/;    if (pgfText.match (regex) !== null) {   alert (pgfText.match (regex)[1]);   }   
}

Viewing all articles
Browse latest Browse all 888

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>